【问题标题】:.Net data structure that combines set and dictionary semantics.Net 数据结构,结合了集合和字典语义
【发布时间】:2011-05-25 16:18:08
【问题描述】:

.Net 是否有一个开箱即用的通用集合类型,它结合了 Set 和 Dictionary 语义,这样我只存储项目,但也可以通过从每个项目派生的某个键进行快速查找?像这样的:

var foos = new KeyedSet<string, Foo>(foo => foo.ID);

foos.Add(new Foo { ID = "X234", Descr = "One foo" });
foos.Add(new Foo { ID = "Q909", Descr = "Another foo" });

Console.WriteLine("Foo Q909 is {0}", foos["Q909"].Descr);

【问题讨论】:

标签: .net collections dictionary set


【解决方案1】:

【讨论】:

  • 完美!我没有听说过System.Collections.ObjectModel 命名空间。非常感谢。
猜你喜欢
  • 1970-01-01
  • 2012-01-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-07-30
  • 2013-01-01
相关资源
最近更新 更多