I could be wrong in understanding what you mean, but it should just be ...
This is the main file.
using System; using IdeaClass; namespace TestIdeas { class Program { static void Main(string[] args) { Ideas i = new Ideas(); Ideas.triggerMany(); Console.ReadLine(); } } }
Then there is the Ideas class:
using System; namespace IdeaClass { public class Ideas { static OtherClass oc = new OtherClass(); public static void triggerMany() { oc.runThing("textual"); } public Ideas() { Ideas.oc.ThingEvent += DoThingHandler; } public void DoThingHandler(string thing) { System.Console.WriteLine(thing); } } }
And then another class.
using System; namespace IdeaClass { class OtherClass { public delegate void DoThing(string text); public event DoThing ThingEvent; public void runThing(string text) { if (ThingEvent != null) { ThingEvent(text); } } } }
This leads to an unsuccessful connection between the class that raises the event and the class with a static call, but it seems to do what you want.
source share