using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication10 { delegate int MathFunction(int int1, int int2); class Program { static int Add(int int1, int int2) { return int1 + int2; } static int Subtract(int int1, int int2) { return int1 - int2; } static int Multiply(int int1, int int2) { return int1 * int2; } static int Divide(int int1, int int2) { return int1 / int2; } static void PrintResult(MathFunction mathFunction, int int1, int int2) { int result = mathFunction(int1, int2); Console.WriteLine(String.Format("Result is {0}", result)); } static void Main(string[] args) { <big>int left = Convert.ToInt32(args[0]);</big> //here i am getting exception char theOperator = args[1][0]; int right = int.Parse(args[2]); MathFunction mathFunction; if (theOperator == '+') mathFunction = Add; else if (theOperator == '-') mathFunction = Subtract; else if (theOperator == '*') mathFunction = Multiply; else mathFunction = Divide; PrintResult(mathFunction, left, right); } } }
args[0]
args
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)