ReSharper 2024.1 Help

Code inspection: Redundant operand in logical conditional expression

Category

Redundancies in Code

ID

RedundantLogicalConditionalExpressionOperand

EditorConfig

resharper_redundant_logical_conditional_expression_operand_highlighting

Default severity

Warning

Language

C#, VB.NET

Requires SWA

No

If the first operand in a conditional OR operator evaluates to false, the value of the entire OR expression is determined by the second operand. Therefore, a constant false as the first operand is redundant and ReSharper suggests removing the expression with the redundant operand:

private static void TestOr(string s) { const bool b = false; bool a = b || s.Contains("."); Console.WriteLine(a); }
private static void TestOr(string s) { const bool b = false; bool a = s.Contains("."); Console.WriteLine(a); }
Last modified: 08 April 2024