我想要做的是,当使用我的程序的人在没有任何内容的情况下点击输入时,它不会导致错误这是程序的一部分:
Console.WriteLine("4.-Ya no quiero jugar >.<");
int opc = Convert.ToInt16(Console.ReadLine());
switch (opc)
{
case 1:
Console.WriteLine("omg");
break;
case 2:
Console.WriteLine("wtf");
break;
default:
Console.WriteLine("Cant do that >.>");
Console.ReadKey();
break;
etc.
}
事情是我使用整数,我试图这样做
string opc1=console.readline();
if (opc =="")
{
console.writeline("nope,try again");
}
else
{ // Brace was omitted in original - Jon
int opc = Convert.ToInt16(Console.ReadLine());
switch (opc)
blah blah.
以及它的不同组合 >.< 和默认值对此不起作用
我希望有人能帮我解决它>.<