如果循环语句中断 [英] if loop statement break
本文介绍了如果循环语句中断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
if(checkBox1.Checked==true && checkBox2.Checked==true)
{
**// check box1 statemet//**
DataSet ds = new DataSet();
ds.Clear();
SqlDataAdapter da = new SqlDataAdapter("select sum(amount) from addtransaction where transactiontype='income'", con);
da.Fill(ds);
richTextBox2.Text = "Total Income : " + ds.Tables[0].Rows[0][0].ToString();
####如何打破这两个陈述?### 3
#### how to break this two statements ??###3
**//check box2 statemet//**
DataSet ds1 = new DataSet();
ds1.Clear();
SqlDataAdapter da1 = new SqlDataAdapter("select sum(amount) from addtransaction where transactiontype='Expense'", con);
da1.Fill(ds1);
richTextBox2.Text = "Total Expense : " + ds1.Tables[0].Rows[0][0].ToString();
推荐答案
为什么要打破?如果您不想执行第二个块代码,则将其添加到else块中。
Why do want to break? If you do not want to execute the second block code then add it in the else block.
if(checkBox1.Checked==true )
{
**// check box1 statemet//**
DataSet ds = new DataSet();
ds.Clear();
SqlDataAdapter da = new SqlDataAdapter("select sum(amount) from addtransaction where transactiontype='income'", con);
da.Fill(ds);
richTextBox2.Text = "Total Income : " + ds.Tables[0].Rows[0][0].ToString();
}
else if(checkBox2.Checked==true)
{
**//check box2 statemet//**
DataSet ds1 = new DataSet();
ds1.Clear();
SqlDataAdapter da1 = new SqlDataAdapter("select sum(amount) from addtransaction where transactiontype='Expense'", con);
da1.Fill(ds1);
richTextBox2.Text = "Total Expense : " + ds1.Tables[0].Rows[0][0].ToString();
}
这篇关于如果循环语句中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文