Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a difference between StringDictionary class and Dictionary<String,String> [duplicate]

System.Collections.Specialized contains StringDictionary http://msdn.microsoft.com/en-us/library/system.collections.specialized.stringdictionary.aspx#Y1626

What's difference with Strong Typed Dictionary in Generics?

like image 542
user310291 Avatar asked Mar 20 '11 14:03

user310291


People also ask

Is dictionary unique c#?

A dictionary, also called an associative array, is a collection of unique keys and a collection of values, where each key is associated with one value. Retrieving and adding values is very fast. Dictionaries take more memory because for each value there is also a key.

What is a dictionary in C#?

In C#, Dictionary is a generic collection which is generally used to store key/value pairs. The working of Dictionary is quite similar to the non-generic hashtable. The advantage of Dictionary is, it is generic type. Dictionary is defined under System. Collection.


1 Answers

StringDictionary comes from .Net 1, which predates generics.

Therefore, unlike Dictionary<String, String>, it doesn't implement any generic interfaces, so it cannot be used with LINQ (unless you Cast())

Also, StringDictionary normalizes all keys to lowercase.
(To make a case-insensitive Dictionary<String, String>, pass StringComparer.OrdinalIgnoreCase; this is also more compatible with Turkey)

like image 64
SLaks Avatar answered Oct 05 '22 22:10

SLaks