《MCTS.C#》(part.4)第五章:流程控制、迴圈與例外狀況處理

 switch

在case中可以使用goto default; 或是goto case “…”;

以避免重覆的程式碼。
switch (input)
{
case “111”:
Console.WriteLine(“…”);
goto case “password”; //goto case “…” , 要記得要有case

case “password”:
Console.WriteLine(“o”);
break;
case “other”:
Console.WriteLine(“other…”);
goto default; //goto label
d[……]

(繼續閱讀)

Read More