Permalink
Fetching contributors…
Cannot retrieve contributors at this time
54 lines (41 sloc) 1003 Bytes

Replace if with switch

Property Value
Id RR0133
Title Replace if with switch
Syntax if statement
Span top if keyword or selected if statement
Enabled by Default

Usage

Before

var ch = stringReader.Read();

if (ch == 10 || ch == 13)
{
    return;
}
else
{
    stringBuilder.Append(ch);
}

After

var ch = stringReader.Read();

switch (ch)
{
    case 10:
    case 13:
        {
            return;
        }

    default:
        {
            stringBuilder.Append(ch);
            break;
        }
}

See Also

(Generated with DotMarkdown)