我正在尝试用C#编写一个简单的计算器.但由于某种原因,程序无法识别2个变量.这是代码的第52行:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Calculator
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter your first number: ");
string num1 = Console.ReadLine();
//Convert the string to a integer and check if it contains a number
try
{
int number1 = Convert.ToInt32(num1);
}
catch (FormatException e)
{
Console.WriteLine("That was not a number!");
}
catch (OverflowException e)
{
Console.WriteLine("Wow, not so many numbers..");
}
Console.WriteLine("Press / * + or -: ");
string symbol …Run Code Online (Sandbox Code Playgroud)