menu

Sunday, August 1, 2010

Get more than one result from a function

Function will give three result SUM, SUB, MUL at one call.

class MyProgram
{
public static void Main()
{
int a = 10, b = 20, c = 0, d = 0, e = 0;

Func(a, b, ref c, ref d, ref e);

Console.WriteLine("Sum= {0}", c);
Console.WriteLine("Sub= {0}", d);
Console.WriteLine("Mul= {0}", e);
Console.ReadLine();
}

public static void Func(int p, int q, ref int r, ref int s, ref int t)
{
r = p + q;
s = p - q;
t = p * q;
}
}

No comments:

Post a Comment