static void Main(string[] args) { ArifmeticOperation arifmeticOperation = (a, b, c) => (a + b + c) / 3; Console.WriteLine("result {0:f2}", arifmeticOperation?.Invoke(2, 3, 5)); Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("Введите арифметическую операцию с 2 членами"); string inputData = Console.ReadLine(); Regex regexNumbers = new Regex(@"\d+"); Regex symbol = new Regex(@"\+|-|\*|\/"); int fistNumber = Convert.ToInt32(regexNumbers.Matches(inputData)[0].Value); int secondNumber = Convert.ToInt32(regexNumbers.Matches(inputData)[1].Value); string arifmeticSymbol = symbol.Match(inputData).Value; ArifmeticOperation ao = null; InitialDelegate(arifmeticSymbol, ref ao); Console.WriteLine(ao.Invoke(fistNumber, secondNumber)); Console.ReadKey(); }