Why is it possible to initialize a Dictionary
like this:
var dict = new Dictionary() {
{ \"key1\", 1 },
{ \"
Your problem stems from the fact that it is an array, not a collection.
var kvps = new KeyValuePair[] {
{ "key1", 1 },
{ "key2", 2 }
};
should really be:
var kvps = new KeyValuePair[] {
new KeyValuePair("key1", 1),
new KeyValuePair("key2", 2)
};
The giveaway is the brackets. []
is an array. {}
is a collection.