小编Die*_*r91的帖子

C#无法识别两个变量

我正在尝试用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)

c# console-application

-2
推荐指数
1
解决办法
154
查看次数

标签 统计

c# ×1

console-application ×1