zoukankan      html  css  js  c++  java
  • break,continue,return 区别

    using System;
    using System.Collections.Generic;
    using System.Text;

    namespace breakcontinue_test
    {
        class Program
        {
            static void Main(string[] args)
            {
                for (int i = 10; i > 3; i--)  //判断变量是否大于3,如果满足条件,开始循环
                {
                    Console.WriteLine("当前变量的值等于{0}", i); //输出变量值
                    break;     //跳出整个for循环   return 的作用跟break一样。
                    Console.WriteLine("看看这句是否输出呢?");   //没有输出说明跳出了循环
                }
                for (int i = 20; i > 13; i--)  //判断变量是否大于13,如果满足条件,开始循环
                {
                    Console.WriteLine("当前变量的值等于{0}", i); //输出变量值
                    continue;  //跳出本次循环,继续执行下次可执行的循环。
                    Console.WriteLine("看看这句是否输出呢?");   //没有输出说明跳出了循环
                }
            }
        }
    }

    总结:break;     //跳出整个for循环   return 的作用跟break一样。 continue;  //跳出本次循环,继续执行下次可执行的循环。

  • 相关阅读:
    QT学习笔记
    局域网摄像头安装与调试
    从0开始搭建视觉检测智能车
    树莓派安装anaconda
    手把手教你搭建视觉检测智能车
    树莓派与Arduino串口通信实验
    树莓派设置关机重启键
    树莓派can通信
    树莓派GPIO使用笔记
    MySQL练习题
  • 原文地址:https://www.cnblogs.com/ljan/p/3192845.html
Copyright © 2011-2022 走看看