static void Main(string[] args) { Console.WriteLine("Enter First Number:"); int value1 = Convert.ToInt16(Console.ReadLine()); Console.WriteLine("Enter Second Number:"); int value2 = Convert.ToInt16(Console.ReadLine()); Arithmetic obj = new Arithmetic(value1, value2); fptr obj1 = new fptr(obj.Add); Console.WriteLine("Addition is:{0}", obj1(value1, value2)); fptr obj2 = new fptr(obj.Sub); Console.WriteLine("Substraction is:{0}", obj2(value1, value2)); fptr obj3 = new fptr(obj.Mul); Console.WriteLine("Multiplication is:{0}", obj.Mul(value1, value2)); fptr obj4 = new fptr(obj.Dev); Console.WriteLine("Division is:{0}", obj4(value1, value2)); }
static void Main(string[] args) { Compare obj = new Compare(); //crete single delegates fptr obj1 = new fptr(obj.Max); Console.WriteLine("Max number is:{0}", obj1(11, 21)); fptr obj2 = new fptr(obj.Min); Console.WriteLine("Min number is:{0}", obj2(21, 11)); //crete multicast delegates mcast del = new mcast(obj.Max); del += new mcast(obj.Min); Console.WriteLine("Min number is:{0}", del(51, 101)); del -= new mcast(obj.Max); Console.WriteLine("Max mnumber is:{0}", del(151, 151)); }