给定以下代码片段:
using System;
using Foo = System.Int32;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
}
}
}
如果我在“Foo”类型别名的声明中删除“System.”,则会出现编译器错误。尽管我在文件顶部使用了System命名空间,但编译器无法找到未限定的“Int32”类型。
为什么会这样?
class Program { static void Main(String[] args) { Int32 x = 0; } }
在命名空间块之外可以正常工作。 - R. Martinho Fernandes