编译器警告(等级 2)CS0469
更新:2007 年 11 月
错误消息
“goto case”值不可隐式转换为类型“type”
使用 goto case 时,必须将 goto case 的值隐式转换为 switch 的类型。
示例
下面的示例生成 CS0469。
// CS0469.cs
// compile with: /W:2
class Test
{
static void Main()
{
char c = (char)180;
switch (c)
{
case (char)127:
break;
case (char)180:
goto case 127; // CS0469
// try the following line instead
// goto case (char) 127;
}
}
}