Skip to content

Latest commit

 

History

History
24 lines (18 loc) · 434 Bytes

GCop430.md

File metadata and controls

24 lines (18 loc) · 434 Bytes

GCop 430

"Use " NotEqualsExpression.HasValue " as negative logic is taxing on the brain."

Rule description

Human brain can understand positive expressions and statements faster than negative ones. To improve code readability it is better to use HasValue rather than != null.

Example

if (myVariable != null)
{
     ...
}

should be 🡻

if (myVariable.HasValue)
{
    ...
}