static void Main(string[] args) { Noti ob = new Noti(); demo o = new demo(); Employee[] arr = new Employee[3]; arr[0] = new Permanant("Akash", 50000); arr[1] = new Temporory("Ganesh", 35000); arr[2] = new Temporory("Vaibhav", 35000); for (int i = 0; i < arr.Length; i++) { arr[i].BonusEvent += ob.wel; arr[i].BonusEvent += ob.msg; arr[i].BonusEvent += o.msg2; } arr[0].giveBonus(5000); arr[1].giveBonus(10000); arr[2].giveBonus(10000); Console.ReadLine(); }
static void Main(string[] args) { Employee[] arr = new Employee[3]; arr[0] = new Permanant("Akash", 50000); arr[1] = new Temporory("Ganesh", 35000); arr[2] = new Temporory("Vaibhav", 35000); Bonus ob = (name, sal, bonus) => { Console.WriteLine("Name: {0}, Salary: {1}, Bonus: {2}", name, sal, bonus); }; for (int i = 0; i < arr.Length; i++) { arr[i].BonusEvent += ob; } arr[0].giveBonus(5000); arr[1].giveBonus(10000); arr[2].giveBonus(10000); Console.ReadLine(); }