Had a great time talking at the North Dallas .NET

User Group last night about C# 3.0. The crowd, once they warmed up, had

lots of good questions and a good time was had by all. If you’re interested

in the code from that talk, it

is posted here. One question came up that was not answered, which is how

you might initialize a Dictionary using the new collection initialization techniques.

I really had intended to research the answer, but by the time I was home from carousing

with folks at the Fox Sports Grill after the meeting, the obviously much more dedicated

Paul Igendorf had already emailed me the answer. Here’s an example:

Dictionary<string, int>

numbers = new Dictionary<string,int>()
{
    {"zero",

0},
    {"one",

1},
    {"two",

2},
    {"three",3}
};

              foreach (string key in numbers.Keys) 
{
    Console.WriteLine(key + "=" +

numbers[key].ToString());
}

Thanks Paul for sharing this!