Mark your class as abstract.
Code:
public abstract MyClass
{
...
}
public MyDerivedClass : MyClass
{
...
}
MyClass myClass = new MyClass(); //not allowed!
MyClass myClass = new MyDerivedClass(); //this is ok
You can also mark individual methods inside a class as abstract to avoid giving them
any default implementation, as shown here:
Code:
public abstract MyClass
{
public abstract void DoSomething();
}
MyClass myClass = new MyClass();//not allowed!