Michael said:
I want to inherit from Bitmap to add a property but I can't because it's
sealed. Is there any reason to seal a class?
Supporting the possibility of inheritance--in a published interface
like the .NET Framework--is a lot of work. You have to design your
class's public and protected members with inheritance in mind, ensuring
that anyone inheriting from the class can insert functionality at
useful points, and ensuring that it's reasonably hard to do stupid
things and jackpot one's self while inheriting.
As well, usually, you expose more about the internal workings of your
class and therefore make it more difficult to change in the future,
because the class's contract with the "public" (which now includes
public users and protected inheritors) is stronger.
An example of a badly designed class that supports inheritance is
PrintPreviewDialog, which allows inheritance but has almost every
behaviour / appearance element you could possibly want to modify in a
child class secured as "private". Some writers prefer to simply seal
the class rather than release nonsense like this.