JustCode

Telerik JustCode can suggest you to convert an if-else statement to a conditional expression where possible.

Note

Language Support

Supported: C#, VB.NET

Not supported: JavaScript, ASP.NET, XAML, HTML

The behavior can be controlled in JustCode Options - JustCode / Options / Code Analysis / Hints / C#.

When "Show hint for convert if statement to conditional expression" option is checked in the options dialog, then Telerik JustCode suggests you to to convert an if-else statement to a conditional expression where possible.

To convert if statement to conditional expression

  1. Position the caret on the condition part of an if-else statement which can be converted to a conditional expression.

  2. Select Convert if statement to conditional expression from the VisualAid's Fixes menu.

    Convert If Statement To Conditional Expression
  3. The result is:

    Convert If Statement To Conditional Expression Result

See Also