Simple sample for Events and Delegates
I wanted to write a small sample to illustrate events and delegates. Here is a compact sample that illustrates it.
using System;
public class EventSample
{
public delegate void EventHandler();
public event EventHandler myeh;
public void Method()
{
Console.WriteLine("Inside Sample Method ... ");
}
public void OnChange()
{
myeh();
}
public static void Main()
{
EventSample es = new EventSample();
es.myeh += new EventHandler(es.Method);
es.OnChange();
}
}