C#数据结构像字典但没有价值 [英] C# Data Structure Like Dictionary But Without A Value

查看:161
本文介绍了C#数据结构像字典但没有价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C#中是否有任何类似字典的数据结构,但只有一个键并且没有值。我基本上想要一个整数列表,我可以快速查找,看看列表中是否有某个值。因为目前的使用,列表不会引起任何性能问题,但是似乎并不适合我的代码的意图。

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> ,并且在.NET框架的3.5版本中可用。如果您使用.NET 2.0版,您可以使用字典并将值设置为 null

这篇关于C#数据结构像字典但没有价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆