static void Main(string[] args) { MyEventPublisher EventPublisher = new MyEventPublisher(); MyEventArgs MyArgs = new MyEventArgs(); MyArgs.MyString = "Hello World"; EventPublisher.MyEvent += new MyDelegateEventHandler(MyHandler); EventPublisher.DoSomething(MyArgs); }
static void Main(string[] args) { MyEventPublisher EventPublisher = new MyEventPublisher(); MyDelegateEventHandler MyAnonymousDelegate = delegate(int x) { Console.WriteLine("Anonymous Event FIRED!"); }; EventPublisher.MyEvent += MyAnonymousDelegate; EventPublisher.DoSomething(); }