Code Snippets 4 U
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();

        }
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *

− 1 = two