【问题标题】:What is special about HashSet<T> in .NET 3.5?.NET 3.5 中的 HashSet<T> 有什么特别之处?
【发布时间】:2010-09-25 05:02:42
【问题描述】:

这是一个有趣的谜题。

我下载了 Snippet Compiler 来尝试一些东西,并想编写以下代码:

using System;
using System.Collections.Generic;

public class MyClass
{
    public static void RunSnippet()
    {
        HashSet<int> h = new HashSet<int>();
    }
}

但是上面的代码不能编译。我明白了:

"类型或命名空间名称'HashSet' 找不到(您是否缺少 使用指令或程序集 参考?)”

显然我不是。它似乎找不到 HashSet,但它在 Systems.Collections.Generic 命名空间中找到了其他类型(例如 List、SortedDictionary)。

对此有何解释?大概 Snippet Compiler 只是在幕后使用标准的 Framework 编译器......

我很想知道为什么这不起作用。

【问题讨论】:

  • 太棒了! 3.5 的 SnippetCompiler 已发布!如果我没有看到你的问题,我永远不会检查!
  • 很高兴通过提出愚蠢的问题来提供帮助! :)

标签: c# .net .net-3.5 code-snippets


【解决方案1】:

是你的参考用途

命名空间:System.Collections.Generic

程序集:System.Core(在 System.Core.dll 中)

3.5 版?

【讨论】:

    【解决方案2】:

    检查 System.Core.dll Snippet Compiler 使用的版本。

    【讨论】:

    • 刚刚下载并检查。默认情况下,Snippet Compiler Live Ultimate 2008 Super Secret Plus Plus Gold Edition 中似乎不包含 System.Core,并为开发人员提供了增强的额外内容...。添加引用允许它编译。
    猜你喜欢
    • 2011-02-18
    • 1970-01-01
    • 1970-01-01
    • 2011-07-13
    • 2011-04-18
    • 2017-02-19
    • 2016-09-30
    • 2019-04-06
    相关资源
    最近更新 更多