Search This Blog

Friday, May 7, 2010

Intializing dictionary in c# 3.0

Programmer Question


I'm having trouble with the following collections initalization:



private Dictionary<string, string> mydictionary = new Dictionary<string, string>()
{
{"key", "value"}
, {"key2", "value2"}
, {"key3", "value3"}
};


I keep getting various compiler errors about the syntax. From what I have googled this should be perfectly valid C# 3.0 code.



The first error that pops up is:



Error   102 ; expecte


What am I doing wrong?





Find the answer here

No comments:

Post a Comment

Related Posts with Thumbnails