編譯器錯誤 CS0159
更新:2007 年 11 月
錯誤訊息
goto 陳述式的範圍內沒有這種標籤 'label'
在 goto 陳述式的範圍內找不到 goto 陳述式所參考的標籤。
下列範例會產生 CS0159:
// CS0159.cs
public class Class1
{
public static void Main()
{
int i = 0;
switch (i)
{
case 1:
goto case 3; // CS0159, case 3 label does not exist
case 2:
break;
}
goto NOWHERE; // CS0159, NOWHERE label does not exist
}
}