obsolete New Hashtable(New CaseInsensitiveHashCodeProvider, New CaseInsensitiveComparer), use IEqual

  • Thread starter Thread starter Eric Donoho
  • Start date Start date
E

Eric Donoho

New warning in .net 2.0... The cumbersome, and difficult to remember
case-insensitive comparer declaration for the hashtable has been
deprecated... It tells me to use IEqualityComparer instead.

So, this syntax is obsolete:

New Hashtable(New CaseInsensitiveHashCodeProvider, New
CaseInsensitiveComparer)

So, the replacement seems to be (after an hour of searching):

New Hashtable(StringComparer.OrdinalIgnoreCase)


The following link is helpful as it describes the "why"... At least
this one will be easy to remember.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/StringsinNET20.asp


Example (vb.net):

Dim d As New Hashtable(StringComparer.OrdinalIgnoreCase)

d.Add("hello", "why do they make this so difficult?")

If d.ContainsKey("HELLO") Then
MsgBox("because")
End If


Hopefully this saves someone else an hour of searching...

Northern State - Is "Georgeous George" a liberal arts, academic,
literary kinda name? Right?
 
Back
Top