Dictionary.TryGetValue 方法 试用记 Mark
2008-06-10 16:42
519 查看
1 if (name == null || name == "")
2 return null;
3 XLine obj;
4 if (xlines.TryGetValue(name, out obj))
5 else
9 // When a program often has to try keys that turn out not to
2 // be in the dictionary, TryGetValue can be a more efficient
3 // way to retrieve values.
4 string value = "";
5 if (openWith.TryGetValue("tif", out value))
6 else
10<br /><span space="preserve"></span><br /> // The indexer throws an exception if the requested key is
14 // not in the dictionary.
15 try
16 catch (KeyNotFoundException)
21
2 return null;
3 XLine obj;
4 if (xlines.TryGetValue(name, out obj))
5 else
9 // When a program often has to try keys that turn out not to
2 // be in the dictionary, TryGetValue can be a more efficient
3 // way to retrieve values.
4 string value = "";
5 if (openWith.TryGetValue("tif", out value))
6 else
10<br /><span space="preserve"></span><br /> // The indexer throws an exception if the requested key is
14 // not in the dictionary.
15 try
16 catch (KeyNotFoundException)
21
相关文章推荐
- Dictionary.TryGetValue 方法
- 二十六、详测 Generics Collections TDictionary(2): ContainsKey、ContainsValue、AddOrSetValue、TryGetValue
- 详测 Generics Collections TDictionary(2): ContainsKey、ContainsValue、AddOrSetValue、TryGetValue
- Dictionary 快速查找---TryGetValue(string key,out string value)
- 按索引index取出指定位置泛型字典Dictionary的key和value的方法举例
- Python 字典(Dictionary) get()方法
- js小练习:利用getElementsByTagName方法、for循环、this指针、数组实现对多个相同元素value值的改变
- 通过keySet方法和get方法遍历map中的每一个value
- Python 字典(Dictionary) get()方法
- Python 字典(Dictionary) get()方法
- ConcurrentDictionary<TKey, TValue>的AddOrUpdate方法
- c# 扩展方法奇思妙用基础篇五:Dictionary<TKey, TValue> 扩展
- Python 字典(Dictionary) get()方法
- getItemValue方法的妙用
- c# 扩展方法奇思妙用基础:Dictionary<TKey, TValue> 扩展
- JAVA NIO 之ByteBuffer的mark、position、limit、flip、reset,get方法介绍
- Dictionary的TryGetValue方法
- Python 字典(Dictionary) get()方法
- DataTime? 的 GetValueOrDefault() 方法
- getItemValue方法的妙用