Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP2stack specificStack: csharp
csharpnull-safetyreadabilitydotnet
Use the null-conditional operator instead of a ternary null check
Replace `x != null ? x.Y : null` with `x?.Y` — the null-conditional operator is shorter and expresses the same intent.
PR: profico-mining-2026-06Created: Jul 26, 2026
Bad example
Old codecsharp
| 1 | var v = node != null ? node.GetAttributeValue("x") : null; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codecsharp
| 1 | var v = node?.GetAttributeValue("x"); |
Explanation (EN)
Objašnjenje (HR)