.NET Dictionary as a Property

后端 未结 8 485
-上瘾入骨i
-上瘾入骨i 2021-02-02 08:30

Can someone point me out to some C# code examples or provide some code, where a Dictionary has been used as a property for a Class.

The examples I have seen so far don\'

8条回答
  •  北海茫月
    2021-02-02 09:25

    Since .net 4.6 you can also define a Dictionary like this:

    private Dictionary Values => new Dictionary()
    {
        { "Value_1", 1},
        { "Value_2", 2},
        { "Value_3", 3},
    };
    

    It's called Expression-bodied members!

提交回复
热议问题