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

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

You May Also Like

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...