2

这是一个有趣的谜题。

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

using System;
using System.Collections.Generic;

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

但是上面的代码不能编译。我得到:

“找不到类型或命名空间名称‘HashSet’(您是否缺少 using 指令或程序集引用?)”

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

对此有何解释?据推测,片段编译器只是在幕后使用标准框架编译器......

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

4

2 回答 2

5

是你的参考用途

命名空间:System.Collections.Generic

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

3.5版?

于 2008-12-03T20:17:00.220 回答
4

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

于 2008-12-03T20:15:57.163 回答