Skip to content

Latest commit

 

History

History
63 lines (48 loc) · 1.15 KB

RR0120.md

File metadata and controls

63 lines (48 loc) · 1.15 KB

Convert ?: to if-else

Property Value
Id RR0120
Title Convert ?: to if-else
Syntax ?: operator that is part of local declaration, assignment or (yield) return statement
Enabled by Default

Usage

Before

string s = (x) ? "a" : "b";

After

string s;
if (x)
{
    s = "a";
}
else
{
    s = "b";
}

Before

string s = (x) ? "a" : (y) ? "b" : "c";

After

string s;
if (x)
{
    s = "a";
}
else if (y)
{
    s = "b";
}
else
{
    s = "c";
}

See Also

(Generated with DotMarkdown)