C# Error
CS0750 – A partial method cannot have the ‘abstract’ modifier
Reason for the Error & Solution
A partial method cannot have access modifiers or the virtual, abstract, override, new, sealed, or extern modifiers.
Because of their special behavior, partial methods are subject to restrictions as to the modifiers they can accept.
To correct this error
- Remove the unauthorized modifier from the method declaration.
Example
The following example generates CS0750:
// cs0750.cs
using System;
public class Base
{
protected virtual void PartG()
{
}
protected void PartH()
{
}
protected virtual void PartI()
{
}
}
public partial class C:Base
{
// All these partial method declarations
// will generate CS0750.
public partial void PartA();
private partial void PartB();
protected partial void PartC();
internal partial void PartD();
virtual partial void PartE();
abstract partial void PartF();
override partial void PartG();
new partial void PartH();
sealed override partial void PartI();
extern partial void PartJ();
public static int Main()
{
return 1;
}
}