Multicasting Delegates
hii all,
First time I am just learning Delegates in c#.
I have faced a conceptual problem.
In books it is written that A Multicasting Delegate should have a return type of Void unless it will throw a run time exception.
But i am written a code snippet with a Multicasting Delegate with a string return type .But it is not throw any exception at all.
Can anybody tell me what is happening here............
Plz somebody help me out...........
The code is given below:
delegate string Delegate_Multicast(int x, int y);
class Class2
{
static string Method1(int x, int y)
{
Console.WriteLine("You r in Method 1");
return "hi";
}
static string Method2(int x, int y)
{
Console.WriteLine("You r in Method 2");
return "hi";
}
public static void Main()
{
Delegate_Multicast func = new Delegate_Multicast(Method1);
func += new Delegate_Multicast(Method2);
string s=func(1,2); // Method1 and Method2 are called
}
|