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 out of switch from final case label ('label')
This error occurs when the last case or default case of a switch statement doesn't end with a jump statement such as:
The following sample generates CS8070:
// CS8070.cs
public class MyClass
{
public static void Main()
{
int i = 2;
int j = 0;
switch (i)
{
case 1:
i++;
break;
// Compiler error CS8070 is reported on the following line.
case 2:
i += 2;
// To resolve the error, uncomment one of the following example statements.
// break;
// return;
// throw new Exception("Fin");
}
switch (j)
{
case 1:
j++;
break;
case 2:
j += 2;
break;
// Compiler error CS8070 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.