What does mean “?” after variable in C#?

Well, ?. is a null-conditional operator

https://msdn.microsoft.com/en-us/library/dn986595.aspx

x?.y

means return null if x is null and x.y otherwise

?? is a null-coalescing operator

https://msdn.microsoft.com/en-us/library/ms173224.aspx

x ?? y

means if x == null return y, otherwise x

Combining all the above

helper?.Settings.HasConfig ?? false

means: return false if

helper == null or
helper.Settings.HasConfig == null

otherwise return

helper.Settings.HasConfig

The code without ?? and ?. if can be rewritten into cumbersome

if (!(helper == null 
        ? false
        : (helper.Settings.HasConfig == null 
             ? false
             : helper.Settings.HasConfig))) 

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)