这是一个有趣的谜题。
我下载了 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)。
对此有何解释?据推测,片段编译器只是在幕后使用标准框架编译器......
我很想知道为什么这不起作用。