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.

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...