namespace _029_goto和return來跳出循環(huán) {
? ? class Program {
? ? ? ? static void Main(string[] args) {
? ? ? ? ? ? //while (true)
? ? ? ? ? ? //{
? ? ? ? ? ? //? ? int num = Convert.ToInt32(Console.ReadLine());
? ? ? ? ? ? //? ? if (num == 0)
? ? ? ? ? ? //? ? {
? ? ? ? ? ? //? ? ? ? goto myLabel;
? ? ? ? ? ? //? ? }
? ? ? ? ? ? //}
? ? ? ? ? ? //myLabel:
? ? ? ? ? ? //Console.WriteLine("跳出循環(huán)了");
? ? ? ? ? ? while (true)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? int num = Convert.ToInt32(Console.ReadLine());
? ? ? ? ? ? ? ? if (num == 0)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? return;//用來終止方法的,表示方法運行結(jié)束,剩余的代碼不執(zhí)行了
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? Console.WriteLine("跳出循環(huán)了");
? ? ? ? ? ? Console.ReadKey();
? ? ? ? }
? ? }
}