C# Compiler Error
CS0418 – ‘class name’: an abstract class cannot be sealed or static
Reason for the Error
You’ll get this error in your C# code when you are trying to mark an abstract class as sealed.
For example, lets try to compile the below code snippet.
using System; namespace DeveloperPublishNamespace { public abstract sealed class Employee { } class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); } } }
You’ll receive the error code CS0418 when you compile the above C# program because you are using the using the sealed keyword on the abstract class. In C#, an abstract class cannot be used for instantiating unless you inherit or derive the abstract class. There won’t be any meaning if you are making the abstract class as sealed. The same applies for the abstract class marked as static as well.
Error CS0418 ‘Employee’: an abstract type cannot be sealed or static DeveloperPublish C:\Users\Senthil\source\repos\ConsoleApp4\ConsoleApp4\Program.cs 5 Active
Solution
You can avoid this error in your C# code by ensuring that you don’t mark the abstract class as either sealed or static.