唯一列表< T>在.NET 2 [英] Unique List<T> in .NET 2
问题描述
什么是
- 最好是通用的
- 独特(IComparable / IEquitable)价值
- preferably generic;
- unique(IComparable/IEquitable) valued
对象 .NET 2 ?
(àla List< T& code>,或来自.NET 3.5的
HashSet< T>
的等效项,但没有有序项)
(à la List<T>
, or an equivalent of HashSet<T>
from .NET 3.5, but without ordered items)
推荐答案
不幸的是,第一个好的框架类是 HashSet ,您只能使用.Net 3.5访问。
Unfortunately, the first good framework class for this is the HashSet, which you will only get access to with .Net 3.5.
如果您在以前的版本中停留,不是很好。最常见的是使用字典类型,其中Key是您尝试存储的值。
If you are stuck in previous versions., the options are not as nice. The most common is to usea Dictionary type where the Key is the value that you are trying to store. You can wrap this in your own class fairly easily.
如果你愿意在框架外部一起工作,那么就有.Net的数据结构集合,例如 NGenerics 。
If you are willing to go outside the framework all together, there are collections of data structures for .Net, such as NGenerics.
这篇关于唯一列表< T>在.NET 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!