   [.net] Events and inheretence...
  So, I have a abstract class that has about 10 events. I'm finding, however, that when I derive from the class, I can't actually invoke the events. So, I have a few questions:1) What is the purpose of making events only callable from the class they're defined in? 2) Any design patterns I can use to get around this obstacle?   
  1- To keep things from triggering the event when they're not supposed to. 2- Depending on the necessity, a common delegate or something like:public event Type OnEvent;protected void TriggerEvent(args){ OnEvent(args); }There's also probably some other ways to get around it, or designs which avoid it entirely but that's pretty simple. Though that won't work nicely with events in interfaces.   ;  That seems like a silly reason to completely break the extensibility of a class. Your method works just fine, though.The problem was, I'm using a stack-based state management system. The engine exposed it's interface via about 20 events in the GameState. Since all GameState's used are derived, the events were useless.   ;  Here is a link to an article on MSDN describing how to raise the event from the base class in the derived class.How to: Raise Base Class Events in Derived Classes (C# Programming Guide)I just flew over the example but I think it is pretty much the same as Telastyn suggested.   ;  Let's say you declare an event like this:public event EventHandler FooHappened;What is actually generated by the C# compiler is this:private EventHandler _FooHappened;public void add_FooHappened( EventHandler e ){  _FooHappened = Delegate.Combine(_FooHappened, e);}public void remove_FooHappened( EventHandler e ){  _FooHappened = Delegate.Remove(_FooHappened, e);}When you add a handler to an event, the following happens:bar.FooHappened += someDelegate;// is transformed by the compiler to this:bar.add_FooHappened( someDelegate );(If you don't believe, run ildasm on an appropriate assembly for yourself.)Obviously, since the actual delegate instance is private, it can only be manipulated by external code (like in a derived class) through the add_* and remove_* methods.   ;  I have pretty the same problem here. I have a base class "eventclass" which i need to access from "theOterClass", but with option to override its memebers in "Program" class.namespace Testing{    class MyInterface    {   public virtual void OnSomethingIsDone(){  Console.WriteLine("OnSomethingIsDone()");   }    }    class MyClass : MyInterface    {   public static void Run()   {  while (true)  { ... //Check every x secnd for new actionif (action == "OnSomethingIsDone") xxxxxx????//^- what shuould i do there, to access ovverrided method?  }   }    }  //Program itself    class Program : MyInterface    {    static void Main(string[] args)   {  MyClass.Run();   }    //i ovverride everything here   public override void OnSomethingIsDone()   {  Console.WriteLine("aaaa"); To see if i can ovverride it correctly   }    }}Can someone help me?   