Re: Statics and inheritance
- From: "Ignacio Machin \( .NET/ C# MVP \)" <ignacio.machin AT dot.state.fl.us>
- Date: Tue, 31 May 2005 09:49:48 -0400
Hi,
Well, if you declare it in Root then you are implying that ALL the derived
classes share the very same value.
If you happen to have the same escenario on each of the derived classes,
then you would have to do the same thing on each one, remember each of them
happen independely of the others.
Not very complicated to do in any case.
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Andrew Ducker" <andrew@xxxxxxxxxxxxx> wrote in message
news:1117542594.968323.298590@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Let's say I have a root class called RootBusinessService
> and I then want to have 25 business service classes based off of it.
>
> And each class has a property that's shared between all instances of it
> - called 'State'. I therefore want all of them to have a static
> property State.
>
> However, I can't declare this static property in RootBusinessService -
> because if I do, the subclasses will all point to that single property.
>
> So I have to declare it in each individual class. 25 times.
>
> Not only that, but if I want it to come up in intellisense for all
> subclasses of RootBusinessServer, I need to create a get/set in the
> root, and override it in each subclass to point to the 'local' static
> property.
>
> Is this right, or am I missing a really easy way to have a static
> property automatically exist in all subclasses of a given class?
>
> Cheers,
>
> Andy D
>
.
- References:
- Statics and inheritance
- From: Andrew Ducker
- Statics and inheritance
- Prev by Date: Re: Ordering items in an array
- Next by Date: Re: Newbie DirectX 9
- Previous by thread: Re: Statics and inheritance
- Next by thread: Highlighting Text in a RichTextBox
- Index(es):
Relevant Pages
|