What does the question mark mean in member access in C #?

Can someone please explain to me what the question mark means in member access in the following code?

Is it part of standard C #? I get parsing errors when trying to compile this file in Xamarin Studio.

this.AnalyzerLoadFailed?.Invoke(this, new AnalyzerLoadFailureEventArgs(AnalyzerLoadFailureEventArgs.FailureErrorCode.NoAnalyzers, null, null));

AnalyzerFileReference.cs line 195

+4
source share
2 answers

The Null Propagation operator is introduced in C # 6 , it will call the method if the object isthis.AnalyzerLoadFailednot null:

this.AnalyzerLoadFailed?.Invoke(this, new AnalyzerLoadFailureEventArgs(AnalyzerLoadFailureEventArgs.FailureErrorCode.NoAnalyzers, null, null));

equally:

if( this.AnalyzerLoadFailed != null)
    this.AnalyzerLoadFailed.Invoke(this, new AnalyzerLoadFailureEventArgs(AnalyzerLoadFailureEventArgs.FailureErrorCode.NoAnalyzers, null, null));

See C # 6.0 - Null Propagation Operator , also you can see here

# 6

+15

# 6

if (this.AnalyzerLoadFailed != null)
    this.AnalyzerLoadFailed.Invoke(this, new AnalyzerLoadFailureEventArgs(AnalyzerLoadFailureEventArgs.FailureErrorCode.NoAnalyzers, null, null));
+6

All Articles