ImmutableDictionary has no constructors defined

Posted by lukasLansky on Stack Overflow See other posts from Stack Overflow or by lukasLansky
Published on 2014-06-04T09:22:33Z Indexed on 2014/06/04 9:24 UTC
Read the original article Hit count: 126

Filed under:
|

So, I would like to write something like this:

var d = new ImmutableDictionary<string, int> { { "a", 1 }, { "b", 2 } };

(using ImmutableDictionary from System.Collections.Immutable). It seems like a straightforward usage as I am declaring all the values upfront -- no mutation there. But this gives me error:

The type 'System.Collections.Immutable.ImmutableDictionary<TKey,TValue>' has no constructors defined

How I am supposed to create a new immutable dictionary with static content?

© Stack Overflow or respective owner

Related posts about c#

Related posts about immutability