M
Michael C
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?
Thanks,
Michael
sealed. Is there any reason to seal a class?
Thanks,
Michael
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?
Thanks,
Michael
Ignacio Machin ( .NET/ C# MVP ) said:Hi,
It's a design decision , it's an indication that there is no further
inheritance expected for that class.
It's a pity, I just want to add some fairly harmless properties like a
Tag property so I can pass some extra info around with the bitmap. It
seams to me that if inheriting the bitmap could cause problems if
certain method are overridden isn't really that big a deal. We can
cause all sorts of problems using the api but we still get to go that
Michael Bray said:While I agree with you in principle and in practice, I can offer the
(obvious?) suggestion to write a class that has a Bitmap as a member, plus
whatever other properties you want to pass around. Then use an instance
of
that class in place of Bitmap, and reference the bitmap member when you
want to use the bitmap itself.
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?
Hi Michael,
In .NET 3.0 (shipping with Windows Vista, so I've heard) there are Extender
methods so you can decorate instances of any object or interface with your
own methods and their implementations.
Dave Sexton said:In .NET 3.0 (shipping with Windows Vista, so I've heard) there are Extender
methods so you can decorate instances of any object or interface with your
own methods and their implementations.
Dave Sexton said:Hi Michael,
Well, I'm indifferent to the name and how Microsoft markets their
products. It provides functionality that will be useful to me and I
suspect that it will be useful to Michael C as well.
Dave Sexton said:Actually your statement is incorrect.
The following code works fine in the
LINQ Preview, C# 3.0 compiler of May 2006. Also, the docs for the C# 3.0
compiler state that extension properties, events and operators are being
considered. Do you know if they've come to a decision whether to include
those features?
The following code allows any instance of an object, of any Type, to have an
associated object at runtime using SetTag and GetTag methods.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.