I want to use a collection initializer for the next bit of code:
public Dictionary GetNames()
{
Dictionary names =
In the following code example, a Dictionary
is initialized with instances of type StudentName
.
Dictionary students = new Dictionary()
{
{ 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}}
};
from msdn