Compiler Warning (level 2) CS0469
The 'goto case' value is not implicitly convertible to type 'type'
When you use goto case
, there must be an implicit conversion from the value of the goto case to the type of the switch.
The following sample generates CS0469.
C#
// 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;
}
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET feedback
.NET is an open source project. Select a link to provide feedback: