Possible pitfalls of using this (extension method based) shorthand

后端 未结 11 1442
孤独总比滥情好
孤独总比滥情好 2020-11-27 20:00

C#6 Update

In C#6 ?. is now a language feature:

// C#1-5
propertyValue1 = myObject != null ? myObject.StringProperty : null; 

// C#         


        
11条回答
  •  一向
    一向 (楼主)
    2020-11-27 20:32

    Here is another solution using myObject.NullSafe(x=>x.SomeProperty.NullSafe(x=>x.SomeMethod)), explained at http://www.epitka.blogspot.com/

提交回复
热议问题