Welcome to MSDN Blogs Sign in | Join | Help

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

    }

}

Published Thursday, July 31, 2008 11:44 PM by thottams@microsoft.com

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# a-foton » Simple sample for Events and Delegates

Friday, August 01, 2008 3:07 AM by a-foton » Simple sample for Events and Delegates

# Need help in Asp.Net

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.

Tuesday, August 26, 2008 5:33 AM by dharmendersharma

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker