C# Error CS0115 – ‘function’ : no suitable method found to override

C# Compiler Error

Error CS0115 – ‘function’ : no suitable method found to override

Reason for the Error

You would receive this error when you mark the method as override whereas the compiler could not find method to override.

For example, try compiling the below code snippet.

abstract public class Class1
{
    public abstract void Function1();
}
abstract public class Class2 
{
    override public void Function1()  
    {
    }
}
public class DeveloperPublish
{
    public static void Main()
    {

    }
}

The class2 contains the function Function1 which has the override as keyword but there is no method to override as it doesnot have any base class to inherit from.

Error CS0115 ‘Class2.Function1()’: no suitable method found to override ConsoleApp1 C:\Users\Senthil\source\repos\ConsoleApp1\ConsoleApp1\Program.cs 7 Active

C# Error CS0115 – 'function' : no suitable method found to override

Solution

You can fix it by making sure that you are inheriting the right base class which contains the method to override.

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Hey, wait!Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.