Compiler Error CS0418
'class name': an abstract class cannot be sealed or static
An abstract class cannot be used to create objects unless it is derived from, so it makes no sense to be sealed. An abstract class cannot meaningfully be static either; abstract classes are designed to support an object hierarchy that will use the abstract class as a base.
The following sample generates CS0418:
C#
// CS0418.cs
public abstract sealed class C // CS0418
{
}
sealed static class S // CS0418
{
}
public class MyClass
{
public static void Main()
{
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET feedback
.NET is an open source project. Select a link to provide feedback: