ReSharper 2024.1 Help

Code Inspection: Ternary expression has identical true and false branches

Category

Potential Code Quality Issues

ID

ConditionalTernaryEqualBranch

EditorConfig

resharper_conditional_ternary_equal_branch_highlighting

Default severity

Warning

Language

C#, VB.NET, JavaScript

Requires SWA

No

This one’s fairly obvious. The following expression:

return condition ? result : result;
Return If(condition, result, result)

is identical to the following

return result;
Return result

since the condition does not affect what is being returned.

Last modified: 15 April 2024