If you give someone fish, they have fish; if you teach them how to fish, you don’t need to give them fish. All posted answers are correct, but no one tells you how to determine the answer for yourself.
The syntax of a collection initializer in C # is "syntactic sugar"; it's just a nicer way to write boring code. When you write:
C c = new C() { p, q, { r, s }, {t, u, v} };
This is the same as if you wrote:
C c; C temporary = new C(); temporary.Add(p); temporary.Add(q); temporary.Add(r, s); temporary.Add(t, u, v); c = temporary;
Now it should be clear how you can understand what to put in the initializer sentence: look at the type and see what the various Add methods take as arguments . In your case, the Add dictionary method takes a key and a value, so the initializer should be { { k1, v1 }, { k2, v2 } , ... }
Make sense?
Eric Lippert
source share