用于存储唯一字符串的集合? [英] Which collection for storing unique strings?

查看:217
本文介绍了用于存储唯一字符串的集合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个像 Dictionary(OF Key,Value)的集合,但我实际上不需要键和值。密钥本身就足够了。所以像 Collection(Key)。它不应该接受重复的键。



我在.NET Framework中查找了几个集合,但是找不到我想要的。目前我滥用 Dictionary(OF String,String)并将值设置为 Nothing 。 >

我是否继续滥用字典(OF T,T)?

解决方案

我认为您想要的是 HashSet< T> 。 p>

I'm looking for a collection just like Dictionary(OF Key, Value) but I don't actually need a key and value. Key itself is enough. So something like Collection(Key). It shouldn't accept duplicate keys.

I've looked up couple of collections in .NET Framework but couldn't find what I want. Currently I'm abusing Dictionary(OF String, String) and setting Value as Nothing all the time.

Shall I just continue abusing Dictionary(OF T,T)?

解决方案

I think what you want is a HashSet<T>.

这篇关于用于存储唯一字符串的集合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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