using System; namespace CSharpConsole { class DelDemo { public void Add(int x, int y) { Console.WriteLine(x + y); } public static string SayHello(string name) { return "Hello " + name; } public delegate void AddDel(int a, int b); public delegate string SayDel(string name); static void Main() { DelDemo obj = new DelDemo(); AddDel ad = new AddDel(obj.Add); SayDel sd = new SayDel (DelDemo.SayHello); ad(100, 50); ad(234, 434); ad(672, 157); Console.WriteLine(sd("AAA")); Console.WriteLine(sd("BBB")); Console.WriteLine(sd("CCC")); Console.ReadLine(); } } }
Tuesday, 12 March 2013
Delegate Example
Labels:
C# basics
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment