编译器错误 CS0179
更新:2007 年 11 月
错误消息
“member”不能是外部的,也无法声明主体
当类成员被标记为 extern 时,意味着该成员的定义位于另一文件中。因此,标记为 extern 的类成员不能在类中定义。请移除 extern 关键字或删除定义。有关更多信息,请参见方法(C# 编程指南)。
下面的示例生成 CS0179:
// CS0179.cs
public class MyClass
{
public extern int ExternMethod(int aa) // CS0179
{
return 0;
}
// try the following line instead
// public extern int ExternMethod(int aa);
public static void Main()
{
}
}