Skip to content

Commit c470eca

Browse files
add CS8070 compiler error (#48282)
* add CS8070 compiler error * make changes from feedback: - add CS8070 entry to TOC - fix some grammar
1 parent 9022706 commit c470eca

File tree

2 files changed

+72
-5
lines changed

2 files changed

+72
-5
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
description: "Compiler Error CS8070"
3+
title: "Compiler Error CS8070"
4+
ms.date: 9/05/2025
5+
f1_keywords:
6+
- "CS8070"
7+
helpviewer_keywords:
8+
- "CS8070"
9+
author: "StuartMosquera"
10+
---
11+
# Compiler Error CS8070
12+
13+
Control cannot fall out of switch from final case label ('label')
14+
15+
This error occurs when the last `case` or `default` case of a [switch statement](../statements/selection-statements.md#the-switch-statement) doesn't end with a jump statement such as:
16+
17+
- [break](../statements/jump-statements.md#the-break-statement)
18+
- [return](../statements/jump-statements.md#the-return-statement)
19+
- [throw](../statements/exception-handling-statements.md#the-throw-statement)
20+
21+
The following sample generates CS8070:
22+
23+
```csharp
24+
// CS8070.cs
25+
public class MyClass
26+
{
27+
public static void Main()
28+
{
29+
int i = 2;
30+
int j = 0;
31+
32+
switch (i)
33+
{
34+
case 1:
35+
i++;
36+
break;
37+
38+
// Compiler error CS8070 is reported on the following line.
39+
case 2:
40+
i += 2;
41+
// To resolve the error, uncomment one of the following example statements.
42+
// break;
43+
// return;
44+
// throw new Exception("Fin");
45+
}
46+
47+
switch (j)
48+
{
49+
case 1:
50+
j++;
51+
break;
52+
53+
case 2:
54+
j += 2;
55+
break;
56+
57+
// Compiler error CS8070 is reported on the following line.
58+
default:
59+
Console.WriteLine("Default");
60+
// To resolve the error, uncomment the following line:
61+
// break;
62+
}
63+
}
64+
}
65+
```

docs/csharp/language-reference/toc.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ items:
192192
- name: when (filter condition)
193193
href: ./keywords/when.md
194194
- name: field
195-
href: ./keywords/field.md
195+
href: ./keywords/field.md
196196
- name: value (implicit parameter)
197197
href: ./keywords/value.md
198198
- name: Query Keywords
@@ -382,8 +382,8 @@ items:
382382
- name: Attributes read by the compiler
383383
items:
384384
- name: Global attributes
385-
displayName: >
386-
AssemblyName, AssemblyVersion, AssemblyCulture, AssemblyFlags, AssemblyProduct, AssemblyTrademark, AssemblyInformationalVersion,
385+
displayName: >
386+
AssemblyName, AssemblyVersion, AssemblyCulture, AssemblyFlags, AssemblyProduct, AssemblyTrademark, AssemblyInformationalVersion,
387387
AssemblyCompany, AssemblyCopyright, AssemblyFileVersion, CLSCompliant, AssemblyTitle, AssemblyDescription, AssemblyConfiguration,
388388
AssemblyDefaultAlias
389389
href: ./attributes/global.md
@@ -396,7 +396,7 @@ items:
396396
DoesNotReturn, DoesNotReturnIf
397397
href: ./attributes/nullable-analysis.md
398398
- name: Miscellaneous
399-
displayName: >
399+
displayName: >
400400
Conditional, Obsolete, Deprecated, Experimental, SetsRequiredMembers, AttributeUsage, AsyncMethodBuilder, InterpolatedStringHandler,
401401
ModuleInitializer, SkipLocalsInit, UnscopedRef, OverloadResolutionPriority. EnumeratorCancellation, CollectionBuilder,
402402
IUnknownConstant, IDispatchConstant, module initializer
@@ -407,7 +407,7 @@ items:
407407
OptionalAttribute, OutAttribute, PreserveSigAttribute, SerializableAttribute, StructLayoutAttribute, IndexerNameAttribute,
408408
DefaultParameterValueAttribute, InAttribute, SpecialNameAttribute, UnmanagedCallersOnlyAttribute, CompilerFeatureRequiredAttribute,
409409
DecimalConstantAttribute, DefaultMemberAttribute, DynamicAttribute, ExtensionAttribute, FixedBufferAttribute, IsByRefLikeAttribute,
410-
IsReadOnlyAttribute, RequiresLocationAttribute, IsUnmanagedAttribute, NullableAttribute, NullableContextAttribute,
410+
IsReadOnlyAttribute, RequiresLocationAttribute, IsUnmanagedAttribute, NullableAttribute, NullableContextAttribute,
411411
NullablePublicOnlyAttribute, ParamArrayAttribute, ParamCollectionAttribute, RefSafetyRulesAttribute, RequiredMemberAttribute,
412412
TupleElementNamesAttribute
413413
href: ./attributes/pseudo-attributes.md
@@ -1878,6 +1878,8 @@ items:
18781878
href: ../misc/cs5001.md
18791879
- name: CS7003
18801880
href: ./compiler-messages/cs7003.md
1881+
- name: CS8070
1882+
href: ./compiler-messages/cs8070.md
18811883
- name: CS8124
18821884
href: ./compiler-messages/cs8124.md
18831885
- name: CS8125

0 commit comments

Comments
 (0)