Convert 'if' to 'switch'
Property | Value |
---|---|
Id | RR0133 |
Applicable Syntax | if statement |
Syntax Span | top if keyword or selected if statement |
Enabled by Default | ✓ |
Usage
Example #1
before.cs
var ch = stringReader.Read();
if (ch == 10 || ch == 13)
{
return;
}
else
{
stringBuilder.Append(ch);
}
after.cs
var ch = stringReader.Read();
switch (ch)
{
case 10:
case 13:
{
return;
}
default:
{
stringBuilder.Append(ch);
break;
}
}
Configuration
roslynator_refactoring.convert_if_to_switch.enabled = true|false