Compiler Error CS0163
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;
}
}
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.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for