C#数据结构像字典,但没有值 [英] C# Data Structure Like Dictionary But Without A Value
问题描述
是否有任何数据结构在C#就是喜欢一个字典,而是只有一个键和不具有价值。我基本上要整型,我可以快速查找和查看某个值在列表中的列表。当然,我目前使用的列表,不会造成任何性能问题,但它只是似乎没有用什么我的code做的目的,以适应良好。
Is there any data structure in C# that is like a dictionary but that only has a key and doesn't have a value. I basically want a list of integers that I can quickly lookup and see if a certain value is in the list. Granted, for my current use, a List would not cause any performance problem, but it just doesn't seem to fit well with the intent of what my code is doing.
推荐答案
是的,这就是所谓的一个 的HashSet< T>
和3.5版本的.NET框架可用。如果您使用的.NET版本2.0,你可以使用一个字典,并设置值空。
Yes, it's called a HashSet<T>
, and available in version 3.5 of the .NET framework. If you use .NET version 2.0, you can use a Dictionary and set values to null.
这篇关于C#数据结构像字典,但没有值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!