初學(xué)者求教
?for (int x = 1; x <= 4; x++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? Console.WriteLine();
? ? ? ? ? ? ? ? Console.Write("hi");
? ? ? ? ? ? ? ? if (x == 3)
? ? ? ? ? ? ? ? ? ? continue;
? ? ? ? ? ? ? ? Console.WriteLine("你好");
? ? ? ? ? ? ? ? ? ? ? ? }
為什么continue如果放在最后一行會(huì)有這么大的區(qū)別。
2017-03-27
因?yàn)閏ontinue是繼續(xù)下一次循環(huán),如果放最后,?只有當(dāng) x = 3的時(shí)候才會(huì)輸出"你好",其他都是繼續(xù)循環(huán)