public static void main(string[] args) { DelegateExample deleg = new DelegateExample(); addNum dele_obj = new addNum(deleg.sum); subNum dele_obj1 = new subNum(deleg.substract); Console.WriteLine(dele_obj(10, 15)); Console.WriteLine(dele_obj1(10, 15)); }
static void Main(string[] args) { Console.WriteLine("Which Operation Would you like to Perform : 1. Addtion 2. Subtraction 3.multiplication 4.division"); int val = Int32.Parse(Console.ReadLine()); // Console.WriteLine($"sel : {sel}"); addNum delegateObj1 = new addNum(sum); subNum delegateObj2 = new subNum(sub); mulNum delegateObj3 = new mulNum(mul); divNum delegateObj4 = new divNum(div); Console.WriteLine("Enter 1st Number :"); int num1 = Int32.Parse(Console.ReadLine()); Console.WriteLine("Enter 2st Number :"); int num2 = Int32.Parse(Console.ReadLine()); CalculatorWithDelegate(val, num1, num2); // delegateObj1(100,50); // delegateObj2(100,50); }