Compiler Error CS0179
'member' cannot be extern and declare a body
When a class member is marked extern, it means that the member's definition is located in another file. Therefore, a class member marked as extern cannot be defined in the class. Either remove the extern
keyword or delete the definition. For more information, see Methods.
The following sample generates CS0179:
C#
// 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()
{
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET feedback
.NET is an open source project. Select a link to provide feedback: