Add breaks to the end of case "Rock"
, case "Scissors"
and case "Paper":
:
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; //<---
}
Switch statement’s cases should have break;
, throw
, goto
, or return
to exit after case is done. This isn’t true only if you have cases stacked like so:
switch(statement)
{
case 1:
case 2:
case 3:
DoSomething();
break;
}
0
solved I see an error CS8070 . How i can fix the error?