哈希集 <- 它在我的电脑上不起作用

发布于 2024-08-17 14:10:14 字数 242 浏览 4 评论 0 原文

我想在我的程序中使用 HashSet。

但我无法声明 HashSet。

我的电脑安装了 Microsoft .Net FrameWork 3.5。

我还声明了名称空间。 (使用 System.Collections.Generic)

但它不起作用。

我如何解决这个问题?

我使用 Visual Studio 2005(c#) 和 Windows 7。

谢谢。

I want to use HashSet in my program.

but I couldn't declare HashSet.

My Computer was installed Microsoft .Net FrameWork 3.5.

and also I declared namespace. (using System.Collections.Generic)

But It didn't work.

How i fix this problem?

i am use visual studio 2005(c#) and Windows 7.

thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

罪歌 2024-08-24 14:10:14

“我使用 Visual Studio 2005(c#) 和 Windows 7。”

那么你没有使用.Net 3.5。您需要在项目中专门引用 System.Core 程序集。

"i am use visual studio 2005(c#) and Windows 7."

Then you're not using .Net 3.5. You need to specifically reference the System.Core assembly in your project.

梦毁影碎の 2024-08-24 14:10:14

表示哈希集是特定类型的哈希集。例如,您可能有一个 HashSetHashSet 等,并且您必须这样声明它。

(我有 Java 背景,但我 97% 确信 C# 中的情况几乎相同)。

The <T> means that a hashset is a hashset of a particular type. So for example, you could have a HashSet<String> or a HashSet<Integer> etc. and you have to declare it as such.

(I'm coming from a Java background but I'm 97% sure it's pretty much the same in C#).

小ぇ时光︴ 2024-08-24 14:10:14

它与java几乎相同。唯一的区别是 C# 中的所有内容都继承自 object(甚至像“string”、“int”等基元)。意思是,将其声明为:

HashSet<string> rather than HashSet<String>

Its pretty much the same as java. The only difference is that EVERYTHING inherits from object in c# (even primitives like 'string','int',etc...). Meaning, declare it as:

HashSet<string> rather than HashSet<String>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文