How can I create a new instance of ImmutableDictionary?

前端 未结 5 1813
慢半拍i
慢半拍i 2020-12-15 15:18

I would like to write something like this:

var d = new ImmutableDictionary { { \"a\", 1 }, { \"b\", 2 } };

(using

5条回答
  •  无人及你
    2020-12-15 15:33

    So far I like this most:

    var d = new Dictionary { { "a", 1 }, { "b", 2 } }.ToImmutableDictionary();
    

提交回复
热议问题