Why is compile time error CS0759 generated?
No defining declaration found for implementing declaration of partial method 'method'.
public partial class Foo
{
public extern partial void SamplePartialMethod(); // CS0759
}
Clearly I did define the defining declaration of the partial method rather than the implementation declaration. Yet compile time error CS0759 is generated?
It does not make sense.
CodePudding user response:
The
extern
modifier is used to declare a method that is implemented externally.
So by including the extern
keyword, you're effectively providing the implementation for the partial method, not the definition.
This code doesn't cause that error because it declares the implementation separately from the declaration:
public partial class Foo
{
public extern partial void SamplePartialMethod();
public partial void SamplePartialMethod();
}