C# Compiler Error
CS0112 – A static member ‘function’ cannot be marked as override, virtual or abstract
Reason for the Error
You will receive this error when you use the static keyword along with any of these keywords for the function definition.
- override
- virtual
- abstract
For example, the below code snippet demonstrates the error CS0112 where the overridden method Function1 also contains the keyword static.
abstract public class Class1 { public abstract void Function1(); } public class Class2 : Class1 { override public static void Function1() { } } public class DeveloperPublish { public static void Main() { } }
Error CS0112 A static member ‘Class2.Function1()’ cannot be marked as override, virtual, or abstract ConsoleApp1 C:\Users\Senthil\source\repos\ConsoleApp1\ConsoleApp1\Program.cs 7 Active
Solution
To fix the above error, remove the static keyword on the methods that have override , virtual or abstract.