Re: C# inheritance broken?
- From: Tom Shelton <tom_shelton@xxxxxxxxxxxxxxxxxx>
- Date: Sat, 27 Jan 2007 21:02:38 -0600
On 2007-01-27, Bruce Wood <brucewood@xxxxxxxxxx> wrote:
A generalized method of converting a base class into a derived class with
the knowledge that the derived class may still require some initialization
would definitely be useful, even if you had to do it via a constructor that
takes an object of the base class as it's argument. The missing syntax, in
vb is
mybase = objBaseClass
In C# I think it would be
base = objBaseClass
In either case, since this is occurring in a constructor in place of the
base.New() or mybase.New statement, the programmer knows he still has to
instantiate and initialize all other private and protected objects in the
derived class.
Mike Ober.
Agreed. That would be nice. I wouldn't need it often, but it would get
one out of some tricky corners. My only point was that the whole "I
have a base class instance and I want to treat it as though it were a
derived class instance" is completely unsafe and therefore runs
against the grain of what .NET is supposed to be all about. Being able
to copy state, though, would be handy.
Reflection :)
--
Tom Shelton
.
- Follow-Ups:
- Re: C# inheritance broken?
- From: Michael D. Ober
- Re: C# inheritance broken?
- References:
- C# inheritance broken?
- From: groups
- Re: C# inheritance broken?
- From: Ignacio Machin \( .NET/ C# MVP \)
- Re: C# inheritance broken?
- From: groups
- Re: C# inheritance broken?
- From: Mythran
- Re: C# inheritance broken?
- From: Ignacio Machin \( .NET/ C# MVP \)
- Re: C# inheritance broken?
- From: Michael D. Ober
- Re: C# inheritance broken?
- From: Bruce Wood
- Re: C# inheritance broken?
- From: Michael D. Ober
- Re: C# inheritance broken?
- From: Bruce Wood
- C# inheritance broken?
- Prev by Date: FileStream
- Next by Date: Re: Boxing and Unboxing ??
- Previous by thread: Re: C# inheritance broken?
- Next by thread: Re: C# inheritance broken?
- Index(es):
Relevant Pages
|
Loading