8 break 和 Continue 之间的区别

来源:互联网 发布:百万公众网络答题2017 编辑:程序博客网 时间:2024/06/14 04:12
break: 直接跳出循环

continue:中断本次循环,继续进行下一次循环

        static void breakvsContinue()        {            for (int i = 0; i < 10; i++)            {                if (i == 0) break;                DoSomeThingWith(i);            }            the break will cause the loop to exit on the first iteration - DoSomeThingWith will never be executed.            for (int i = 0; i < 10; i++)            {                if (i == 0) continue;                DoSomeThingWith(i);            }        }


0 0
原创粉丝点击