Of Code and Me

Somewhere to write down all the stuff I'm going to forget and then need

Auto Initialize a Dictionary in C# September 16, 2009

Filed under: Uncategorized — Rupert Bates @ 4:05 pm

I couldn’t find an example of using the new auto initialization syntax in C# 3.0 with a Dictionary so here is one:

var dict = new Dictionary<string, string> { { "key1", "value1" }, { "key2", "value2" } };
Advertisements
 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s