当我编译以下代码时,我不断收到“CS1513:}预期”错误。错误发生在 user_input 方法的左括号处。我是 C# 新手,仍在学习。对不起,如果我遗漏了一些明显的东西。我已经搜索了多个论坛,但没有找到解决方案。在此先感谢您的帮助!using System;namespace App{class AppClass{ static void Main() { } void user_input() { public int input1; public int input2; public string operation; while (operation != "+" or operation != "-") { Console.WriteLine("Would you like to Add or Subtract?"); operation = Convert.ToString(Console.ReadLine()); } Console.WriteLine("Please enter the first input:"); input1 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Please enter the second input:"); input2 = Convert.ToInt32(Console.ReadLine()); } void do_math() { public int output; if (operation == "+") { output = input1+input2; } else { output = input1-input2; } } void display() { Console.WriteLine("The answer is {0}", output); }}}
1 回答
- 1 回答
- 0 关注
- 449 浏览
添加回答
举报
0/150
提交
取消