跳转语句
break 终止并跳出循环; continue 终止当前这一次循环,开始下一轮循环 ; return 终止它所在的方法的执行; goto 转到一个标号地址去执行 ;
using System;
namespace test
{
class exe
{
static void Main()
{
string s = "hello world !#%$";
foreach (char c in s)
{
if (c == '!') goto start; //跳出
if (c == ' ') continue; // 终止当前这一次循环,开始下一轮循环
Console.Write(c);
}
start: // goto语句标号
odd();
}
public static void odd()
{
int a = 3;
while (true)
{
if (a == 3) break; //终止并跳出循环
}
if (a % 2 == 0) return; //终止它所在的方法的执行
}
}
}