using System;
class Delegate_Demo
{
public delegate void mydel(); //delegate declaration named mydel
public void method1()
{
Console.WriteLine("Method1");
}
public void method2()
{
Console.WriteLine("Method2");
}
public static void Main()
{
Delegate_Demo d=new Delegate_Demo();
mydel m1=new mydel(d.method1); //m1 contain's only one reference i.e method1
m1();
mydel m2=new mydel(d.method1);
m2+=new mydel(d.method2); //assinging multiple reference
m2(); //m2 contains two reference i.e method1 and method2
}
}
/*output will be
Method1
Method1
Method2
*/
About Me
Friday, December 18, 2009
A simple Program in C#
class First
{
public static void Main()
{
System.Console.WriteLine("Welcome to C# programming");
}
}
// you can save this file as extenstion .cs and then compile it...
For compilng -> open commnd prompt
write -> csc filename.cs press enter
For Run-> write only filename on command prompt
{
public static void Main()
{
System.Console.WriteLine("Welcome to C# programming");
}
}
// you can save this file as extenstion .cs and then compile it...
For compilng -> open commnd prompt
write -> csc filename.cs press enter
For Run-> write only filename on command prompt
Subscribe to:
Posts (Atom)