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()





    public static void Main()


        EventSample es = new EventSample();

        es.myeh += new EventHandler(es.Method);




Comments (2)

  1. dharmendersharma says:

    Hi Thomas

    i am Dharmender, can u do one favour for me in Asp.Net.

    actually i am developing a web application in which user could create a table and on every point or intersection where a row line and table line cross each other there shuld some clickable point.

    please help me logically or by the code.

    thanks in Advance.