Events inheritance

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jproot

    #1

    Events inheritance

    Hi
    I use the following syntax to have events inherited from base to child classes which works nicely (virtual and override keyword on events). But I am wondering if it is a "supported" way of using events since I never saw it used anywhere in MSDN documentation/samples?! Or it will just break when I upgrade to .NET Framework 2.x in the coming years

    namespace MyNamespac

    public delegate void MyDel()

    public class MyBase

    public virtual event MyDel MyEvent
    public void MyMethod2(

    MyEvent()



    public class MyDerived : MyBas

    // Override base class event so that it can
    // be raise from child (here!
    public override event MyDel MyEvent

    public void MyMethod(
    { // Raise event. Without the virtual/override keywords,
    // child classes are not allowed to raise events declared
    // in their base clas
    MyEvent()




    Thank
    JPRoot
Working...