且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

goto语句问题

更新时间:2023-02-11 09:02:37

一个break语句(而不是goto)会导致您需要的效果.
A break statement (instead of the goto) would cause the effect you need.


hii,

嘿,伙计,除了您的代码外,什么都不做
参见下面的示例代码

hii,

hey dude nothing to do other than your code
see below sample code

int i=0;
            while (i < 70)
            {
                for (int j = 0; j < 100; j++)
                {
                    if ( j == 87)
                    {
                        goto outer;
                        Console.WriteLine("in loop" + j.ToString());
                        Console.WriteLine("in loop" + (j+1).ToString());
                    }
                }
            outer:
                Console.WriteLine("out loop" + i.ToString());
                Console.WriteLine("out loop" + (i + 1).ToString());
                i++;
            }
            Console.ReadKey();




这将始终打印




this will always print

Console.WriteLine(&quot;out loop&quot; + i.ToString());
                Console.WriteLine(&quot;out loop&quot; + (i + 1).ToString())




希望你能得到想要的.
编码愉快




hope you will get what you want.
have happy coding