當我編譯以下代碼時,我不斷收到“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 回答
- 0 關注
- 480 瀏覽
添加回答
舉報
0/150
提交
取消