Remove unnecessary equality operator (IDE0100)

Property Value
Rule ID IDE0100
Title Remove unnecessary equality operator
Category Style
Subcategory Unnecessary code rules
Applicable languages C# and Visual Basic

Overview

This style rule flags unnecessary equality operator when comparing a non-constant boolean expression with a constant true or false. This rule has no associated code style option.

Example

// Code with violations
if (x == true) { }
if (M() != false) { }

// Fixed code
if (x) { }
if (M()) { }
' Code with violations
If x = True Then
End If

If M() <> False Then
End If

' Fixed code
If x Then
End If

If M() Then
End If

See also