以下程序的朋友在我编译时给了我错误。错误在StringfromMonths中。表明它在当前上下文中不存在。它在当前比赛中是如何不存在的,因为我想从枚举 Months中获取一个常量字符串,同时将其转换为字符串。
感谢您的回应!
using System;
enum Months
{
September,
Octobar,
November = 11,
December,
}
class Montest
{
public static void Main()
{
string s;
Console.WriteLine("Please choose a month");
Console.WriteLine("September");
Console.WriteLine("Octobar");
Console.WriteLine("November");
Console.WriteLine("December");
s = Console.ReadLine();
switch (s)
{
case "September":
Console.WriteLine("You have selected September which has the Valuve {0}",StringfromMonths(Months.September));
break;
case "October":
Console.WriteLine("You have selected September which has the Valuve {0}", StringfromMonths(Months.September));
break;
case "November":
Console.WriteLine("You have selected September which has the Valuve {0}", StringfromMonths(Months.September));
break;
case "December":
Console.WriteLine("You have selected September which has the Valuve {0}", StringfromMonths(Months.September));
break;
}
}
}