在VS2015预览版中使用C#6.0,我们有一个新的运算符,?.可以像这样使用:
?.
public class A { string PropertyOfA { get; set; } } ... var a = new A(); var foo = "bar"; if(a?.PropertyOfA != foo) { //somecode }
它到底是做什么用的?
c# operators c#-6.0
c# ×1
c#-6.0 ×1
operators ×1