static void Main(string[] args) { Stringlength len = delegate(string s, string g) { int l = s.Length; int p = g.Length; int t = l + p; Console.WriteLine(t); }; len("Hello", "Priya"); Console.WriteLine("---------------------------"); Console.WriteLine("enter basic salary"); int bs = Convert.ToInt32(Console.ReadLine()); Employee emp = new Employee(); DoAllCalculations dac = delegate(int basicSal) { emp.CalculateGrossSalary(bs); emp.CalculateNetSalary(bs); Console.WriteLine("Gross Salary= " + emp.GrossSalary); Console.WriteLine("Net Salary= " + emp.NetSalary); }; dac(bs); Console.ReadLine(); }
static void Main(string[] args) { Employee emp = new Employee(); DoAllCalculations obj1 = new DoAllCalculations(emp.CalculateGrossSalary); DoAllCalculations obj2 = new DoAllCalculations(emp.CalculateNetSalary); DoAllCalculations cal = (DoAllCalculations)MulticastDelegate.Combine(obj1, obj2); Console.WriteLine("enter basic salary"); int bs = Convert.ToInt32(Console.ReadLine()); //cal(bs); //Console.WriteLine("Gross Salary" + emp.GrossSalary); //Console.WriteLine("Net Salary" + emp.NetSalary); EmpShowCalculations += cal; EmpShowCalculations(bs); Console.WriteLine("Gross Salary" + emp.GrossSalary); Console.WriteLine("Net Salary" + emp.NetSalary); Console.ReadLine(); }