Old question, but I found this helpful. It turns out that there is also a specialized class for a dictionary using a string for both a key and a value:
private static readonly StringDictionary SegmentSyntaxErrorCodes = new StringDictionary { { "1", "Unrecognized segment ID" }, { "2", "Unexpected segment" } };
Edit: Comment from Chris user below, using Dictionary<string, string> over StringDictionary usually preferable, but will depend on your situation. If you are dealing with an older code base, you can restrict it to StringDictionary . Also note that the following line:
myDict["foo"]
returns null if myDict is a StringDictionary , but an exception will be thrown in the case of Dictionary<string, string> . See the SO post he mentioned for more information that is the source of this change.
areyling Mar 29 '11 at 15:08 2011-03-29 15:08
source share