public Form1() { InitializeComponent(); var simpleCalculator = new SimpleCalculator(); buttons = new Dictionary<Button, Func<string, string, string>> { {btnAdd, simpleCalculator.Add}, {btnSubtract, simpleCalculator.Subtract}, {btnMultiply, simpleCalculator.Multiply}, {btnDivide, simpleCalculator.Divide} }; foreach (var button in buttons.Keys) button.Click += (b, e) => MessageBox.Show(buttons[(Button) b](txtNum1.Text, txtNum2.Text)); }
public static void Main(string[] args) { SimpleCalculator simpleCalculator = new SimpleCalculator(); }
public static void InitCalculator() { testCalculator = new SimpleCalculator(); }