I'm new to coding so this might not be the best way to do things. I'm just writing codes to get used to it and understand it better. I was trying to make a calculator which would run in Visual Studios' cmd. I'm trying to collect the data the user is inputting and see if it's "+, -, *, or /," and if it is then it should continue, but if it's not then they should get a message and retry(i haven't wrote this part of the code yet). I made an array of "+, -, *, and /" and am trying to tell the if statement that if it doesn't equal these values, the message should be displayed to retry, but it gives me an error saying you can't assign != to string values.
double user_Input;
string user_inputOperation;
double user_secondInput;
double answer;
string[] operations = { "+", "-", "*", "/" };
Console.WriteLine("Type in a number: " );
user_Input = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Type an operation(+, -, *, /): ");
user_inputOperation = Console.ReadLine();
if (user_inputOperation != operations) // problem occurs here
{
Console.WriteLine("That's not right, try: +, -, *, or /");
user_inputOperation = Console.ReadLine();
}
Console.WriteLine("Type in another number");
user_secondInput = Convert.ToDouble(Console.ReadLine());
if (user_inputOperation == "+")
{
answer = user_Input + user_secondInput;
Console.WriteLine("The answer is: ");
Console.WriteLine(answer);
}
Console.ReadKey();
}
}
}