Does anyone know if there is a way I can insert values into a C# Dictionary when I create it? I can, but don't want to, do
dict.Add(int, "string")
for each item if there is something more efficient like:
Dictionary<int, string>(){(0, "string"),(1,"string2"),(2,"string3")};
You can instantiate a dictionary and add items into it like this:
There's whole page about how to do that here:
http://msdn.microsoft.com/en-us/library/bb531208.aspx
Example:
This isn't generally recommended but in times of uncertain crises you can use
You were almost there:
Just so you know as of C# 6 you can now initialize it as follows
Much cleaner :)