Possible pitfalls of using this (extension method based) shorthand
问题 C#6 Update In C#6 ?. is now a language feature: // C#1-5 propertyValue1 = myObject != null ? myObject.StringProperty : null; // C#6 propertyValue1 = myObject?.StringProperty; The question below still applies to older versions, but if developing a new application using the new ?. operator is far better practice. Original Question: I regularly want to access properties on possibly null objects: string propertyValue1 = null; if( myObject1 != null ) propertyValue1 = myObject1.StringProperty; int