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 dic
2                 oerderby s.key
3                 select s.value
4 
5 foreach( KeyValuePair<int, string> s in result)
6 {
7     response.write("Key:{0}, Value:{1}", s.Key, s.Value)
8 }
View Code