June 5, 2007
Hi Guys
I got the following program from the website. Address is given. I couldn’t understand the following code in the program. Please anybody explain.
ph = (ProcessHandler) Delegate.Combine(ph, new ProcessHandler(Process));
Thank you
//Delegates:Multicasting
//http://www.java2s.com/Code/CSharp/Language-Basics/DelegatesMulticasting.htm
using System;
public class DelegatesMulticasting
{
delegate void ProcessHandler(string message);
static public void Process(string message)
Console.WriteLine("Test.Process(\"{0}\")", message);
}
public static void Main()
User user = new User("George");
ProcessHandler ph = new ProcessHandler(user.Process);
ph("Wake Up!");
public class User
string name;
public User(string name)
this.name = name;
public void Process(string message)
Console.WriteLine("{0}: {1}", name, message);
/*
George: Wake Up!
Test.Process("Wake Up!")
*/