C# Error CS0750 – A partial method cannot have the ‘abstract’ modifier

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

  1. 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;  
    }  
}  

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

C# Compiler Error CS0442 – ‘Property’: abstract properties cannot have private accessors Reason for the Error You’ll get this error...
This is a really simple one . Below is a simple example of an enum called “Designation” defined with the...
This blog post explain the usage of the Checked Block in .NET and how you can use them in Visual...