CS8070控件不能超出带有最终标签盒的开关
("case"Rock":") , ("case"Scissors":") , ("case"Paper":")
{
class Program
{
static void Main(string[] args)
{
string Player1 = Console.ReadLine();
Console.Clear();
string Player2 = Console.ReadLine();
switch (Player1)
{
case "Rock":
switch (Player2)
{
case "Rock":
Console.WriteLine("Draw");
break;
case "Scissors":
Console.WriteLine("Win Player1");
break;
case "Paper":
Console.WriteLine("Win Player2");
break;
}
switch (Player1)
{
case "Scissors":
switch (Player2)
{
case "Rock":
Console.WriteLine("Win Player2");
break;
case "Scissors":
Console.WriteLine("Draw");
break;
case "Paper":
Console.WriteLine("Win Player1");
break;
}
switch (Player1)
{
case "Paper":
switch (Player2)
{
case "Rock":
Console.WriteLine("Win Player1");
break;
case "Scissors":
Console.WriteLine("Win Player2");
break;
case "Paper":
Console.WriteLine("Draw");
break;
}
}
}
}
}
答案 0 :(得分:0)
在TypeError: unsupported operand type(s) for /: 'int' and 'NoneType'
,case "Rock"
和case "Scissors"
的末尾添加中断点:
case "Paper":
Switch语句的案例在完成案例后应退出switch (Player1)
{
case "Rock":
switch (Player2)
{
case "Rock":
Console.WriteLine("Draw");
break;
case "Scissors":
Console.WriteLine("Win Player1");
break;
case "Paper":
Console.WriteLine("Win Player2");
break;
}
switch (Player1)
{
case "Scissors":
switch (Player2)
{
case "Rock":
Console.WriteLine("Win Player2");
break;
case "Scissors":
Console.WriteLine("Draw");
break;
case "Paper":
Console.WriteLine("Win Player1");
break;
}
switch (Player1)
{
case "Paper":
switch (Player2)
{
case "Rock":
Console.WriteLine("Win Player1");
break;
case "Scissors":
Console.WriteLine("Win Player2");
break;
case "Paper":
Console.WriteLine("Draw");
break;
}
break; //<---
}
break; //<---
}
break; //<---
}
,break;
,throw
或goto
。仅当您将箱子堆叠成这样时,情况并非如此:
return