public override void Exec() { Common.Calculate calc = (x, y) => x + y; Console.WriteLine(calc(3, 4)); // Displays 7 calc = (x, y) => x * y; Console.WriteLine(calc(3, 4)); // Displays 12 }
public override void Exec() { Common common = new Common(); Common.Calculate calc = common.Add; Console.WriteLine(calc(3, 4)); // Displays 7 calc = common.Multiply; Console.WriteLine(calc(3, 4)); // Displays 12 }
public override void Exec() { Common.Calculate calc = (x, y) => { Console.WriteLine("Adding numbers... "); return(x + y); }; int result = calc(3, 4); // Displays: Adding numbers... }