Re: Overriding properties and events

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Scott M. (s-mar_at_nospam.nospam)
Date: 09/07/04


Date: Tue, 7 Sep 2004 10:27:49 -0400

No, Shadowed members replace the implementation of the base class member.
The difference between Shadows and Overrides is that to Override, you need
permission from the base class (the base class member must be declared as
Overrideable). With Shadows, you do not need "permission" from the base
class.

"Edward Diener" <eddielee@tropicsoft.com> wrote in message
news:%23$%238917kEHA.208@TK2MSFTNGP12.phx.gbl...
> Scott M. wrote:
>> Only if the base class has that item marked as overrideable. If not,
>> you'll need to use Shadows.
>
> I assume when you say Shadows you mean that the derived class creates a
> property or event with the same name as the base class and calls down to
> the
> base class as needed.
>
> What in the documentation tells me if the item is marked as overrideable ?
> If I look at the MSDN documentation for the .NET framework and I see a
> property for a class, I see no mention of overrideable in any language
> example for get or set functions. Can you point me to a property in the
> documentation which shows this ?
>
> As far as events are concerned, I was thinking of the ability to override
> the adding, removing, and/or raising of an event. Yet documentation for an
> event tells me nothing about these individual event functions for a given
> event but just about the event itself. For my own events I make them
> virtual
> in C++ and, I believe, all functions are virtual in C#. Can I override the
> add_XXX, remove_XXX, or raise_XXX for a public event ? What abouyt for a
> protected event ?
>
>>
>>
>> "Edward Diener" <eddielee@tropicsoft.com> wrote in message
>> news:%23s5gdm7kEHA.3988@tk2msftngp13.phx.gbl...
>>> Is it possible for a derived class to override a property and/or
>>> event of its base class ?
>
>



Relevant Pages

  • Re: What can I store in LPARAM
    ... I'm not saying you're wrong, but with my call back up to the base class, ... may choose to override it completely, or by adding code before or after ... comments below regarding leaf. ... This means that a subclass can't change the method body behind ...
    (microsoft.public.vc.mfc)
  • Re: Overriding properties and events
    ... >> Only if the base class has that item marked as overrideable. ... >> you'll need to use Shadows. ... > What in the documentation tells me if the item is marked as overrideable? ... > As far as events are concerned, I was thinking of the ability to override ...
    (microsoft.public.dotnet.general)
  • Re: How many bytes per Italian character?
    ... override the InitState() function so it needs to be pure virtual. ... derived classes call up to them anyway; ... both the base class and derived class. ...
    (microsoft.public.vc.mfc)
  • Re: Overriding "OnXXX" versus adding event handler
    ... to touch base functionality and not to deal with component ... Either for base class or for my class. ... For example, you can either write a new OnPaint override, or you can ... In other words, override when you can, add an event handler if you can't. ...
    (microsoft.public.dotnet.framework)
  • Re: VB.Net Polymorphic Bug!
    ... The entire point of "Shadows" is that they are not polymorphic! ... MainForm.Widget does not override Form.Widget. ... > Can't override Base class 'X' because of different structure. ...
    (microsoft.public.dotnet.languages.vb)