C# Compiler Error
CS0113 – A member ‘function’ marked as override cannot be marked as new or virtual
Reason for the Error
You will receive this error when you have used both the new and the override keyword for the method declaration.
In C#, the new and the override keyword are mutually exclusive.
abstract public class Class1 { public abstract void Function1(); } public class Class2 : Class1 { override new public void Function1() { } } public class DeveloperPublish { public static void Main() { } }
In the above code the new and override keyword is used on the function Function1 and hence you will receive the error as shown below.
Error CS0113 A member ‘Class2.Function1()’ marked as override cannot be marked as new or virtual ConsoleApp1 C:\Users\Senthil\source\repos\ConsoleApp1\ConsoleApp1\Program.cs 7 Active
Solution
To fix the above error, remove the new keyword when using the override.