using System;
delegate int ArithOp(int x,int y);
class MathOperation
{
public static int Add(int a,int b)
{
return a+b;
}
static public int Sub(int a,int b)
{
return a-b;
}
}
class DelegateTest
{
static void Main()
{
ArithOp AddOp = new ArithOp(MathOperation.Add);
ArithOp SubOp = new ArithOp(MathOperation.Sub);
int result1 = AddOp(200,100);
int result2 = SubOp(200,100);
Console.WriteLine("Result 1 = "+result1+"\nResult 2 = "+result2);
Console.ReadKey();
}
}
Output:-
No comments:
Post a Comment