KeyValuePair<TKey, TValue>是DictionaryEntry的泛型版本
2013-03-04 14:31
495 查看
如同Dictionary<TKey, TValue>是HashTable的泛型版本一样,KeyValuePair<TKey, TValue>是DictionaryEntry的泛型版本。
Dictionary与HashTable内部是基于hash算法的,而SortedDictionary和SortedList是基于Red Black Tree(红黑树)的。
DictionaryEntry:
KeyValuePair<TKey, TValue>:
OO与面向接口:
Dictionary与HashTable内部是基于hash算法的,而SortedDictionary和SortedList是基于Red Black Tree(红黑树)的。
DictionaryEntry:
Hashtable openWith = new Hashtable(); // Add some elements to the hash table. There are no // duplicate keys, but some of the values are duplicates. openWith.Add("txt", "notepad.exe"); openWith.Add("bmp", "paint.exe"); openWith.Add("dib", "paint.exe"); openWith.Add("rtf", "wordpad.exe"); // When you use foreach to enumerate hash table elements, // the elements are retrieved as KeyValuePair objects. Console.WriteLine(); foreach (DictionaryEntry de in openWith) { Console.WriteLine("Key = {0}, Value = {1}", de.Key, de.Value); }
KeyValuePair<TKey, TValue>:
Dictionary<string, string> openWith = new Dictionary<string, string>(); // Add some elements to the dictionary. There are no // duplicate keys, but some of the values are duplicates. openWith.Add("txt", "notepad.exe"); openWith.Add("bmp", "paint.exe"); openWith.Add("dib", "paint.exe"); openWith.Add("rtf", "wordpad.exe"); foreach( KeyValuePair<string, string> kvp in myDictionary ) { Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value); }
OO与面向接口:
相关文章推荐
- KeyValuePair<TKey, TValue>泛型用法
- C# KeyValuePair<TKey,TValue>的用法【转】
- C# Dictionary的用法 KeyValuePair<TKey, TValue> 结构
- C#基础第四天-作业-Hashtable-list<KeyValuePair>泛型实现名片
- C#基础第四天-作业答案-Hashtable-list<KeyValuePair>泛型实现名片
- Dictionary、List<KeyValuePair<i>>的组合使用
- 获取KeyValuePair<string, object>)泛型结构的默认值
- KeyValuePair<byte, string> 类型的数据如何绑定到ComboBox控件上
- c# 泛型集合Dictionary&lt;TKey,TValue&gt;
- NSUnknownKeyException', reason: '[<UIApplication 0x8a58320> setValue:forUndefinedKey:]
- C# KeyValuePair<TKey,TValue>的用法-转载
- Android Post参数提交 List<NameValuePair>,web端获取数据
- 在hibernate中 以Collection<Entity> 替换Map<Key, List<Value>结构
- Mvvm combobox绑定Dictionary<Key,Value>问题
- android关于HashMap<String, Integer>取最大的value,并找出key。
- iOS [<NSObject 0x170204110> setValue:forUndefineKey:]: this class is not key value coding-compliant
- Dictionary<TKey, TValue>.ContainsKey 方法 不区分大小写
- Hadoop Writable深度复制及读取任意<key,value>序列文件
- xjh struts标签版本比较老的,<s:iterator >没有var属性的嵌套循环 使用<s:property value='#id.xxx'>
- c# 泛型集合Dictionary<TKey,TValue>