Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Control cannot fall through from one case label ('label') to another
When a switch statement contains more than one switch section, you must explicitly terminate each section, including the last one, by using one of the following keywords:
If you want to implement "fall through" behavior from one section to the next, use goto case #
.
The following sample generates CS0163.
// CS0163.cs
public class MyClass
{
public static void Main()
{
int i = 0;
switch (i) // CS0163
{
// Compiler error CS0163 is reported on the following line.
case 1:
i++;
// To resolve the error, uncomment one of the following example statements.
// return;
// break;
// goto case 3;
case 2:
i++;
return;
case 3:
i = 0;
return;
// Compiler error CS0163 is reported on the following line.
default:
Console.WriteLine("Default");
// To resolve the error, uncomment the following line:
//break;
}
}
.NET feedback
.NET is an open source project. Select a link to provide feedback: