7
我花了几个小时试图找出为什么我的通用字典(字符串,字符串)不忽略大小写。不区分大小写字典不工作
这里是我的代码:
Dim test As New System.Collections.Generic.Dictionary(Of String, String)(System.StringComparison.OrdinalIgnoreCase)
test.Add("FROG", "1")
Console.WriteLine(test.ContainsKey("frog"))
控制台 “假” 每一次展示。它应该显示“真实”。
如果我使用:
Console.WriteLine(test."frog"))
我得到一个KeyNotFoundException。
看起来好像Comparer参数被完全忽略。
这是怎么回事?
哇好眼睛,现在我还记得我为什么不能忍受隐式转换。 – Josh 2011-06-15 02:36:18