goto

作者:追风剑情 发布于:2014-8-30 20:46 分类:C#

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

标签: C#

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号