So I have almost completed my program but I keep getting this error for the subtraction operator. I have searched throughout my book and the internet but can find no fix for this. Is anybody able to tell me what is wrong with this code?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication14
{
class Program
{
static void Main(string[] args)
{
int int1;
int int2;
char oper;
Console.Write("Enter first integer: ");
int1 = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter operator (+,-,*, / or %)");
oper = Convert.ToChar(Console.ReadLine());
Console.Write("Enter first integer: ");
int2 = Convert.ToInt32(Console.ReadLine());
if(oper == '+')
Console.Write("Answer is: " + int1 + int2);
if (oper == '-')
Console.Write("Answer is: " + int1 - int2);
if(oper == '*')
Console.Write("Answer is: " + int1 * int2);
if(oper == '/')
Console.Write("Answer is: " + int1 / int2);
if(oper == '%')
Console.Write("Answer is: " + int1 % int2);
Console.ReadKey();
}
}
}
():Console.Write("Answer is: " + (int1 - int2));