problem in delegate?

namespace review_of_c
{
class Program
{

public delegate int m(int x, int y);

static void Main(string[] args)
{
m res= new m(sum);
res += new m(mult);
int d=res(5,6);
Console.WriteLine(d);

}
public static int sum(int x, int y)
{
int z = x + y;
return z;

}
public static int mult(int x, int y)
{
int z = x * y;
return z;

}

}

this code give me one result for one fuction (mult), why? i want to obtain the both functions result (mult)and(sum) , plz help me.

Comments

  • ivandroflyivandrofly Guinea-Bissau

    Hi #yamoo11,
    What is going to happen is your delegate will be invoked two times the first you will not see the result. :) you can see the execution by pressing F11.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion