Make dictionary read only in C#

后端 未结 6 585
执笔经年
执笔经年 2020-12-18 20:24

I have a Dictionary> and would like to expose the member as read only. I see that I can return it as a IReadOnlyDictionar

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-18 21:02

    Given the fact that you're specifically looking for a read-only Dictionary>, you're basically looking exactly for a Lookup.

    The Dictionary object has a ToLookup() extension.

提交回复
热议问题