StringDictionary vs Dictionary<>

  • Thread starter Thread starter Peter K
  • Start date Start date
P

Peter K

Hi

are there any benefits in using StringDictionary over Dictionary<string,
string> ?

It appears they achieve the same thing... (I could be wrong of course).


thanks,
Peter
 
are there any benefits in using StringDictionary over Dictionary<string,
string> ?

It appears they achieve the same thing... (I could be wrong of course).

The only benefit would be that you could compile your code in .NET
1.1, which didn't have generics (and thus didn't have
Dictionary<TKey,TValue>).

Jon
 
Peter K said:
Hi

are there any benefits in using StringDictionary over Dictionary<string,
string> ?

StringDictionary compares the keys always case insensitive by converting any
string to lower case before use.
This may be disirable or not.

Christof
 
StringDictionary compares the keys always case insensitive by converting any
string to lower case before use.
This may be disirable or not.

One alternative for Dictionary<> to achieve the case insensitivity but
preserving the case of the keys themselves is to specify the
IEqualityComparer to use.

The MSDN docs for Dictionary<TKey,TValue>(IEqualityComparer<TKey>) has
this has an example.

Jon
 

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

Back
Top