這裏是我的源代碼,一切都很好,直到我到達輸出,我不能得到這個工作。 Visual Studio不喜歡我在輸出部分中標記的// OUTPUT。將代碼轉換爲月份代碼遇到問題
我需要添加或更改以使其工作?
static void Main(string[] args)
{
int monthNumber;
string monthName;
//INPUT
Console.WriteLine("Please enter the number of the month");
monthNumber = Convert.ToInt16(Console.ReadLine());
//PROCCESSESS
if (monthNumber == 1)
{
monthName = "January";
}
else if (monthNumber == 2)
{
monthName = "February";
}
else if (monthNumber == 3)
{
monthName = "March";
}
else if (monthNumber == 4)
{
monthName = "April";
}
else if (monthNumber == 5)
{
monthName = "May";
}
else if (monthNumber == 6)
{
monthName = "June";
}
else if (monthNumber == 7)
{
monthName = "July";
}
else if (monthNumber == 8)
{
monthName = "August";
}
else if (monthNumber == 9)
{
monthName = "September";
}
else if (monthNumber == 10)
{
monthName = "October";
}
else if (monthNumber == 11)
{
monthName = "November";
}
else if (monthNumber == 12)
{
monthName = "December";
}
//space to increase readability
Console.WriteLine(Environment.NewLine);
//OUTPUT
Console.WriteLine("Month:" + monthName);
Console.ReadLine();
}
「Visual Studio不喜歡我擁有的」意思是什麼? – dtb
你在哪裏遇到問題?那是什麼? –
//輸出我得到一個未分配的變量,但其分配 – user1820059