Reputation: 3683
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.
Upvotes: 2
Views: 1069
Reputation: 2540
If a class is sealed some optimizations can be performed. i.e. the clr could emit .call instruction rather than a .callvirt
Upvotes: 2
Reputation: 62532
Because you might want to have public constructors but not allow anyone to derive from your class
Upvotes: 9