我看到错误CS8070。我该如何解决错误?

时间:2018-11-03 05:04:56

标签: c#

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;
                                    }
                            }
                    }
            }
        }

1 个答案:

答案 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;throwgoto。仅当您将箱子堆叠成这样时,情况并非如此:

return