To use initialization syntax like this:
var contacts = new ContactList
{
{ \"Dan\", \"dan.tao@email.com\" },
{ \"Eric\", \"ceo@google.com\" }
};
<
I'd love to have the initializer syntax for immutable types(both collections and normal types). I think this could be implemented with a special constructor overload using a syntax similar to params
.
For example something like this:
MyClass(initializer KeyValuePair[] initialValues)
But unfortunately the C# team didn't implement such a thing yet :(
So we need to use a workaround like
MyClass(new KeyValuePair[]{...})
for now