Skip to content

Commit 26e68a7

Browse files
Creating CS8515 (#32010)
* Removing CS8515 * Adding 8515 to toc.yml * Adding Cs8515 compiler message * Apply suggestions from code review Co-authored-by: Bill Wagner <wiwagn@microsoft.com>
1 parent 9a84b88 commit 26e68a7

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
description: "Compiler Error CS8515"
3+
title: "Compiler Error CS8515"
4+
ms.date: 10/24/2022
5+
f1_keywords:
6+
- "CS8515"
7+
helpviewer_keywords:
8+
- "CS8515"
9+
---
10+
# Compiler Error CS8515
11+
12+
Parentheses are required around the switch governing expression.
13+
14+
## Example
15+
16+
The following samples generates CS8515:
17+
18+
Missing parentheses: `(` `)`:
19+
20+
```csharp
21+
// CS8515.cs
22+
int x = 5;
23+
switch x
24+
{
25+
case 5:
26+
break;
27+
}
28+
```
29+
30+
Missing curly brackets: `{` `}`:
31+
32+
```csharp
33+
// CS8515.cs
34+
int x = 5;
35+
switch (x)
36+
case 5:
37+
break;
38+
```
39+
40+
## The correct format
41+
42+
```csharp
43+
int x = 5;
44+
switch (x)
45+
{
46+
case 5:
47+
break;
48+
}
49+
```
50+
51+
For more information, see [Switch](../statements/selection-statements.md#the-switch-statement)

docs/csharp/language-reference/compiler-messages/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,6 +1709,8 @@ items:
17091709
href: cs8803.md
17101710
- name: CS8812
17111711
href: cs8812.md
1712+
- name: CS8515
1713+
href: cs8515.md
17121714
- name: CS9043
17131715
href: cs9043.md
17141716
- name: CS9050

docs/csharp/misc/sorry-we-don-t-have-specifics-on-this-csharp-error.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,6 @@ f1_keywords:
436436
- "CS8512"
437437
- "CS8513"
438438
- "CS8514"
439-
- "CS8515"
440439
- "CS8516"
441440
- "CS8517"
442441
- "CS8518"

0 commit comments

Comments
 (0)