鸟语天空
goto
post by:追风剑情 2014-8-30 20:46

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();
        }
    }
}

运行结果

goto.png

评论:
发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容