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

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top