Search code examples
c#nullablesyntactic-sugar

Name of expression?


I wrote some code a while ago, but I forgot the name of the syntactic sugar I used and can't find it anymore. I guess it had something with nullable in its name but I am not entirely sure.

That is what I did:

Instead of writing something like this

if(ReturningFunktion() != null)

{ 
   ReturningFunktion().AnotherFunktion();

}

you can write

ReturningFunktion()?.AnotherFunktion();

I can't remember what the ?. bit was called.


Solution

  • This is a Null-conditional operator. You can always try to search such stuff or open Microsoft Documentation on C#: Click me