Permalink
Fetching contributors…
Cannot retrieve contributors at this time
53 lines (34 sloc) 1002 Bytes

RCS1206: Use conditional access instead of conditional expression

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

Examples

Code with Diagnostic

var x = new Foo();

// ...

        string s = (x != null) ? x.ToString() : null; // RCS1206

Code with Fix

string s = x?.ToString();

Code with Diagnostic

int? x = null;

// ...

int i = (x != null) ? x.Value.GetHashCode() : 0; // RCS1206

Code with Fix

int i = x?.GetHashCode() ?? 0;

See Also

(Generated with DotMarkdown)