using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace gotoTest { class Program { static void Main(string[] args) { switch(2){ case 1: Console.WriteLine("case 1"); break; case 2: goto case 1; break; } for (int i = 0; i < 100; i++) for (int j = 0; j < 100; j++) if (j == 3) goto OutFor; else Console.WriteLine("i="+i+", j="+j); OutFor: //标记语句 Console.WriteLine("完毕!"); Console.ReadKey(); } } }
运行结果