So I am doing homework and I am stuck on one spot. I have to write a calculator that takes 2 numbers and either +, -, *, / or % and then it will do the appropriate math. I got the numbers part and the error checking for that down, but the characters part is messing me up. I have tried IndexOf and IndexOfAny and it says there is no overload method that contains 5 arguments. I got a similar response from Contains.
Here is what I have, please help! Thank you so much for any assistance you can offer!
Console.Write("\r\nPlease enter either +, -, * or / to do the math.\r\n");
ReadModifier:
inputValue = Console.ReadLine();
if (inputValue.IndexOfAny("+" , "-" , "*" , "/" , "%"))
{
modifier = Convert.ToChar(inputValue);
goto DoMath;
}
else
{
Console.Write("\r\nPlease enter either +, -, * or / to do the math.\r\n");
goto ReadModifier;
}
1 Answer