怎么用枚举令程序正常运行。关键是switch语句的问题。
//请输入星期几的第一个字母来判断一下是星期几,如果第一个字母一样,则继续 判断第二个字母。
class Program
{
static void Main(string[] args)
{
string data;
char[] myChar = new char[9]; ;
Console.WriteLine("请输入星期几?(全写或者简写,首字母大写)");
data = Console.ReadLine();
myChar = data.ToCharArray();
switch (myChar[0]) {
case M:
Console.WriteLine("Today is Monday.");
break;
case T:
if (myChar[1] == 'u')
{
Console.WriteLine("Today is Tuesday.");
}
else {
Console.WriteLine("Today is Thursday.");
}
break;
case W:
Console.WriteLine("Today is Wednesday.");
break;
case F:
Console.WriteLine("Today if Friday.");
break;
case S:
if (myChar[1] == 'a')
{
Console.WriteLine("Today is Saturday.");
}
else {
Console.WriteLine("Today is Sunday.");
}
break;
default:
Console.WriteLine("您的输入有误!");
break;
}
Console.ReadKey();
}
|
|