zoukankan      html  css  js  c++  java
  • continue 语句将控制权传递给它所在的封闭迭代语句的下一次迭代

    continue 语句将控制权传递给它所在的封闭迭代语句的下一次迭代。

    Collapse 图像示例

    在此示例中,计数器最初是从 1 到 10 进行计数,但通过将 continue 语句与表达式 (i < 9) 一起使用,跳过了 continue 与 for 循环体末尾之间的语句。

      CopyCode image复制代码
    // statements_continue.cs
    using System;
    class ContinueTest 
    {
        static void Main() 
        {
            for (int i = 1; i <= 10; i++) 
            {
                if (i < 9) 
                {
                    continue;
                }
                Console.WriteLine(i);
            }
        }
    }

    输出

     
    9
    10
     实际项目中应用
     
      /// <summary>
            /// 保存到数据库中
            /// </summary>
            public void SaveFileToData(System.Windows.Forms.ProgressBar prg)
            {
                string sql = "delete from Pro_B_ByComPanyInfoData where [Year]='" + this.tlsCmb.Text + "' and ByComPanyID='" + Pioneer.ByCompanyInfo.PubShare.ByCompanyID + "'";
                Pioneer.OperatorData.Delete(sql, Pioneer.PublicConnString.GetConnString);
                prg.Visible = true;
                prg.Minimum = 0;
                prg.Maximum = this.axF1Book1.NumSheets * 100;
                for (Int16 i = 1; i <= this.axF1Book1.NumSheets; i++)
                {
                    axF1Book1.Sheet = i;
                    for (int j=1;j <=100;j++)
                    {
                        prg.Value = prg.Value + 1;
                        string Value = this.axF1Book1.get_EntrySRC(i, j, 3);//单元格中输入的数值
                        string FiledsID = this.axF1Book1.get_EntrySRC(i, j, 1);//字段编号
                        string FiledsName = this.axF1Book1.get_EntrySRC(i, j, 2);//字段名称
                        if (FiledsName.Trim() == "")
                        {
                            continue;
                        }
                        string TableName = this.axF1Book1.get_SheetName(i).ToString();//得到名称
                        string TableID = Pioneer.OperatorData.GetString("ID", "Pro_B_ByComPanyInfo", "Where [Name]='" + TableName + "'", Pioneer.PublicConnString.GetConnString);//
                        string SheetID = i.ToString();//得到表单编号
                        string SheetName = this.axF1Book1.get_SheetName(i).ToString();//得到表单名称
                        string Year = this.tlsCmb.Text;//年度
                        string ByComPanyID = Pioneer.ByCompanyInfo.PubShare.ByCompanyID;//被审计单位编号
                        SaveDataToDb(Value, FiledsID, FiledsName, TableID, TableName, SheetID, SheetName, Year, ByComPanyID);
                    }
                }
                prg.Visible = false;
            }
     
  • 相关阅读:
    设置IIS允许下载.config文件
    SQL Server 触发器
    MVC参数自动装配
    sql之left join、right join、inner join的区别
    C# 之泛型详解
    Frameset使用教程
    网页引用Font Awesome图标
    ubuntu下apache2 安装 配置 卸载 CGI设置 SSL设置
    深入理解JAVA I/O系列二:字节流详解
    深入理解JAVA I/O系列三:字符流详解
  • 原文地址:https://www.cnblogs.com/secbook/p/2655357.html
Copyright © 2011-2022 走看看