首页 > 代码库 > C#中Dictionary的用法

C#中Dictionary的用法

Dictionary<string, string>是一个泛型

举例:

1 Dictionary<int, string> dic = new Dictionary<int, string>();2 3 dic.add(1,"asd");4 dic.add(2,"dssa");5 6 string a=dic[1];
View Code
1 var result=from s in dic2                 oerderby s.key3                 select s.value4 5 foreach( KeyValuePair<int, string> s in result)6 {7     response.write("Key:{0}, Value:{1}", s.Key, s.Value)8 }
View Code

 

C#中Dictionary的用法