Fetching contributors…
Cannot retrieve contributors at this time
31 lines (21 sloc) 761 Bytes

RCS1202: Avoid NullReferenceException

Property Value
Id RCS1202
Category Usage
Default Severity Info
Enabled by Default
Supports Fade-Out -
Supports Fade-Out Analyzer -


Code with Diagnostic

string s = items.FirstOrDefault().ToString(); // RCS1202

Code with Fix

string s = items.FirstOrDefault()?.ToString();

See Also

(Generated with DotMarkdown)