Why this matters
Prevents runtime crashes and clarifies intended fallback behavior.
Guard all potentially-null references with null checks, null-coalescing, or pattern matching before dereferencing.
Prevents runtime crashes and clarifies intended fallback behavior.
Side-by-side examples engineers can pattern-match during review.
var city = user.Address.City.ToLower();var city = user?.Address?.City?.ToLower() ?? "unknown";user.Address.Cityuser?.Address?.City ?? "unknown"From the same buckets as this rule.
Check if loops use equality operators (== or !=) in termination conditions. These can lead to infinite loops if the condition is never met exactly. Instead, use relational operators like < or > for safer loop termination.