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