1. if 语句
for (int
{
if
{
continue;
}
else if
{
MessageBox.Show("今天是晴天");
break;
}
MessageBox.Show("i=:"
}
2. switch 多分支语句
for (int
{
switch
{
case
MessageBox.Show("今天是阴天");
break;
case
MessageBox.Show("今天下大雨");
break;
case
MessageBox.Show("今天是晴天");
break;
default:
break;
}
}
1.1 循环语句
1. while 语句、
int
while
{
i1++;
if
{
break;
}
MessageBox.Show("i=:"
}
2. do...while 语句
do
{
i1++;
if
{
MessageBox.Show("循环结束");
return;
}
MessageBox.Show("i=:"
} while
3. for 语句
for (int
{
switch
{
case
MessageBox.Show("今天是阴天");
break;
case
MessageBox.Show("今天下大雨");
break;
case
MessageBox.Show("今天是晴天");
break;
default:
break;
}
}
4. foreach 语句
ArrayList a = new ArrayList();
StringBuilder s1 = new StringBuilder();
StringBuilder s2 = new StringBuilder();
StringBuilder s3 = new StringBuilder();
StringBuilder s4 = new StringBuilder();
a.Add(s1.Append("扩视"));
a.Add(s2.Append("机器"));
a.Add(s3.Append("视觉"));
a.Add(s4.Append("实训基地"));
foreach (var item in
{
MessageBox.Show(item.ToString());
}
1.2 跳转语句
1. break 语句
2. continue 语句
3. return 语句