您的位置:首页 > 产品设计 > UI/UE

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: