Skip to content

Latest commit

 

History

History
68 lines (55 loc) · 946 Bytes

File metadata and controls

68 lines (55 loc) · 946 Bytes
layout page
title CC0073
tagline AddBracesToSwitchSectionsAnalyzer

|TypeName|AddBracesToSwitchSectionsAnalyzer | |Check Id | CC0073 | |Category | Refactoring | |Severity | Hidden |

Cause

Add curly braces to a switch statement.

Example

{% highlight csharp %} int value = 2; switch (value) { case 1: Console.WriteLine(1); break; case 2: Console.WriteLine(2); break; default: Console.WriteLine(0); break; } {% endhighlight %}

Code fix

A code fix will be presented to you that will transform the code.

{% highlight csharp %} int value = 2; switch (value) { case 1: { Console.WriteLine(1); break; } case 2: { Console.WriteLine(2); break; } default: { Console.WriteLine(0); break; } } {% endhighlight %}

![Code fix]({{ BASE_PATH }}/assets/images/CC0073/codefix0.png)

Related rules

TBD

See also

TBD