int caseSwitch = 2;
switch (caseSwitch)
{
case 1:
Console.WriteLine("Case 1");
break;
case 2:
Console.WriteLine("Case 2");
break;
default:
Console.WriteLine("Default case");
break;
}
the switch is like multiple "if" statements. if the case value matches the switch condition the code for that case is executed, if there is a break inside that "case", the switch statement is exited and the remaining case checks are not performed. the default will execute if the code reaches that point in the "switch" without hitting a break before that.
the return; after the } exits the current function or procedure.
in the current example if there was no "break;" in case 2 the output would be:
Case 2
Default Case
with the break it would be:
Case 2