C# return、continue、break
return 终止当前进程 可用循环判断,验证,等功能
if (ew == v) { PublicControlLib.Class.PublicProperties.ShowSuccess(this, "请检查后提交!", 2000); return; }
continue 终止本次循环 进行下一次循环 用作在循环中进行筛选数据
for(int a = 0;a <Fg1Count;a++) { if (FG1.Rows[a].DefaultCellStyle.BackColor == Color.Red) continue; if (FG1.Rows[a].Visible == false) continue; DataRow Crow = DTmain.NewRow(); Crow["唯一码"] = FG1.Rows[a].Cells[1].Value.ToString(); Crow["价格"] =FG1.Rows[a].Cells[5].Value; DTmain.Rows.Add(Crow); }
break 跳出当前的循环、继续进行外围的循环
for (int a = 0; a < dataGridViewX1.Rows.Count; a++) { for (int b = 0; b < dataGridViewX1.Columns.Count; b++) { if (dataGridViewX1.Rows[a].Cells[b].Value == "") { break; } } }