IL 標籤格式為 名稱:(如 IL_0000:),br 指令可無條件跳轉至任意標籤。
// IL 代碼
.method private hidebysig static int32 abc() il managed {
.locals (int32 V_0)
ldc.i4.s 20
br.s a2
ldc.i4.s 30
a2: ret
}
執行流程:
br.s a2 跳至 a2:,略過 ldc.i4.s 30。ret 返回堆疊頂值 20。輸出:20。
這是所有高階控制結構(if、循環、break、continue、goto)在 IL 層級的統一基礎——標籤與分支指令。