唯一列表< T>在.NET 2

人气:1,170 发布:2022-09-10 标签: .net collections .net-2.0 unique

问题描述

什么是

preferably通用的; 唯一(IComparable的/ IEquitable),价值 preferably generic; unique(IComparable/IEquitable) valued

集合对象的 .NET 2

(点菜的名单,其中,T> ,或等效的的HashSet< T> 从.NET 3.5,但是没有订购项目)

(à 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.

如果你是停留在previous版本,该选项是不一样漂亮。最常见的是USEA词典类型,其中最关键的是您要存储的值。您可以在自己的类相当容易换这个。

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.

482