In the following code example, a Dictionary is initialized with instances of type Student.
Dictionary<int, StudentName> students = new Dictionary<int, StudentName>()
{
{ 111, new StudentName {FirstName="Sachin", LastName="Karnik", ID=211}},
{ 112, new StudentName {FirstName="Dina", LastName="Salimzianova", ID=317}},
{ 113, new StudentName {FirstName="Andy", LastName="Ruth", ID=198}}
};
Note the three pairs of braces in each object initializer. The innermost braces enclose the object initializer for the Scores list. The next set encloses the initializer for the Student, and the outermost braces enclose the initializer for the key/value pair that will be added to the students Dictionary. Finally, the whole collection initializer is enclosed in braces.