Search code examples
c#constructorsubclasssealed

private constructor, subclassing and sealed


If one can prevent subclassing by declaring private constructor in the base class, why do we need "sealed" keyword? Is it so because CLI can optimize it better? maybe.

Thanks.


Solution

  • Because you might want to have public constructors but not allow anyone to derive from your class