private static double WorkWithNumbers(double a, double b, Funck <double, double, double> numbers) { double result = numbers(a, b); if (GetMessage != null) { GetMessage($"{result}"); } return(result); }
private static void WorkWithDelegate() { Circle circuit = new Circle(Circuit); GetMessage += Show; Console.Write($"Circuit: {circuit(22.5)}"); Console.WriteLine(); circuit = new Circle(Area); Console.Write($"Area: {circuit(22.5)}"); Console.WriteLine(); circuit = new Circle(Volume); Console.Write($"Volume: {circuit(22.5)}\n"); Console.WriteLine("=============================="); Funck <double, double, double> numbers = OnePlusTwo; Console.Write("Addition: "); double numb = WorkWithNumbers(22.5, 12.2, numbers); Console.WriteLine(); Console.Write("Subtraction: "); numb = WorkWithNumbers(22.5, 12.2, (a, b) => a - b); Console.WriteLine(); Console.Write("Multi: "); numb = WorkWithNumbers(22.5, 12.2, (a, b) => a * b); Console.WriteLine(); ClassCounter classCounter = new ClassCounter(); classCounter.Handler += Message; classCounter.Count(); }