可能重复: .NET中是否有只读的通用字典?
嗨,大家好,
我意识到可以将列表作为只读集合返回:
var list = new List<string>(); return list.AsReadOnly();
我想为像Dictionary或HashSet这样的数据结构编写类似的代码,但我没有找到实现这一目标的方法.有没有办法将Dictionary或HashSet作为只读集合返回?
谢谢.
c# data-structures
c# ×1
data-structures ×1