相关疑难解决方法(0)

问号和点运算符是什么?在C#6.0中意味着什么?

在VS2015预览版中使用C#6.0,我们有一个新的运算符,?.可以像这样使用:

public class A {
   string PropertyOfA { get; set; }
}

...

var a = new A();
var foo = "bar";
if(a?.PropertyOfA != foo) {
   //somecode
}
Run Code Online (Sandbox Code Playgroud)

它到底是做什么用的?

c# operators c#-6.0

309
推荐指数
3
解决办法
18万
查看次数

标签 统计

c# ×1

c#-6.0 ×1

operators ×1