Make dictionary read only in C#

后端 未结 6 834
一向
一向 2020-12-18 20:37

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:05

    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.

提交回复
热议问题