using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace EventProgram
{
public delegate void delFun(); // delegate is created
class Program
{
event delFun dlfEvent; // event is created
public void EventCreator()
{
dlfEvent = new delFun(EventHandler); // the binding is done
}
private void EventHandler()
{
Console.WriteLine("Yeah I have handled the event.");
}
static void Main(string[] args)
{
Program p = new Program();
p.EventCreator(); // call the part of object that creates event
p.dlfEvent(); // call the event
Console.ReadKey();
}
}
}
Event Program C#
