Console Application for calling Event using Delegate in C# 1.1 and 2.0 (Dot Net)

Google+ Pinterest LinkedIn Tumblr +

using System;

namespace evnt

{

delegate void del();

class evnt

{

static void Main()

{

evnt1 n = new evnt1();

n.show1();

evnt a = new evnt();

            n.evnt2 += new del(a.show2);

n.evnt2 += new del(n.show1);

            n.show();  

Console.ReadLine();

}

public void show2()

{

Console.WriteLine(“Event Fired”);

}

}

class evnt1

{

public event del evnt2;

public void show()

{

Console.WriteLine(“Are you there again”);

if(evnt2 != null)

{

evnt2();

}

Console.WriteLine(“HELLO”);

}

public void show1()

{

Console.WriteLine(“Are you there “);

}

}

}

Share.

About Author

Leave A Reply