LinkedList
that store key/value pairs, you
will need to supply pairs of initializers, as shown here:
SortedList lst =
new SortedList() { {1, "One"}, {2, "Two" }, {3, "Three"} };
The compiler passes each group of values as arguments to
Add( )
. Thus, the first pair of
initializers is translated into a call to
Add(1, “One”)
by the compiler.
Because the compiler automatically calls
Add( )
to add initializers to a collection,
collection initializers can be used only with collections that support a public implementation
of
Add( )
. Therefore, collection initializers cannot be used with the
Do'stlaringiz bilan baham: |