Queston的回答感謝我做了多種方法一碼中的一類,但是當我嘗試運行它,它說預期類,委託,枚舉,接口或結構
預期的類,委託,枚舉,接口或結構
上的兩個方法,不是主要的方法。我四處閱讀,發現有人遇到同樣的問題,並且案例是方法不在課堂上。但無法弄清楚如何解決這個問題。有小費嗎?
PS:我是相當新的編碼;)
using System;
namespace Testing
{
public class Calculator
{
public static void Main (string[] args)
{
string answer;
Console.WriteLine ("Would you like to divide or multiply? Type your choice.");
Start:
answer = (Console.ReadLine());
if (answer == "multiply")
{
MultiplyingMethod;
}
{
else if (answer == "divide")
{
DividingMethod;
}
}
else
{
Console.WriteLine ("Please type multiply or divide.");
goto Start;
}
}
}
public static void DividingMethod()
{
double num01;
double num02;
Console.Write ("Enter a number to be divided");
num01 = Convert.ToInt32 (Console.ReadLine());
Console.Write ("Enter a number to divide by");
num02 = Convert.ToInt32 (Console.ReadLine());
Console.WriteLine (num01 + " divided by " + num02 + " is equal to " + num01/num02);
Console.WriteLine ("");
Console.ReadKey();
}
public static void MultiplyingMethod()
{
double num01;
double num02;
Console.Write ("Enter a number to be multiplied");
num01 = Convert.ToInt32 (Console.ReadLine());
Console.Write ("Enter a numeber to multiply by");
num02 = Convert.ToInt32 (Console.ReadLine());
Console.WriteLine (num01 + " multiplied by " + num02 + " equals " + num01 * num02);
Console.WriteLine ("");
Console.ReadKey();
}
}
}
好像你需要檢查括號 – Grundy
這裏:轉到開始; } } } public static void DividingMethod() – matcheek
omg,goto ...D: – khlr