Using C# 3.0, we can initialize objects without their constructors for syntactical reasons. Such as ..
ClassName c = new ClassName =
{
Property1 = "Value"
}
I was wondering how this works with Dictionaries and adding the items to them. Any ideas?
class Foo
{
public Dictionary<string,int> DictionaryObject { get; set; }
}
Foo f = new Foo =
{
// ???
}
Thank you for your time!!
1 Answer