How to define a must inherit class

You mark the class as abstract (this is the C# analogue to the VB.NET Must Inherit).

This will ensure it can't be instantiated directly.

From the linked MSDN article:

The abstract modifier indicates that the thing being modified has a missing or incomplete implementation. The abstract modifier can be used with classes, methods, properties, indexers, and events. Use the abstract modifier in a class declaration to indicate that a class is intended only to be a base class of other classes. Members marked as abstract, or included in an abstract class, must be implemented by classes that derive from the abstract class.

(emphasis mine)


Use the abstract modifier.

public abstract class MyClass()
{
    ...
}

Tags:

C#

Oop