相关疑难解决方法(0)

是什么 "??" 运营商?

我想知道代码中的??标志C#.它是为了什么?我该如何使用它?

怎么样int??它是一个可以为空的int吗?

也可以看看:

?? Null Coalescing Operator - >合并是什么意思?

c# coalesce operators null-coalescing-operator

31
推荐指数
7
解决办法
2729
查看次数

C#中的Coalesce运算符?

我想我记得在C#中看到类似于?:三元运算符的东西,它只有两个部分,如果不是null则返回变量值,如果是,则返回默认值.像这样的东西:

tb_MyTextBox.Text = o.Member ??SOME OPERATOR HERE?? "default";
Run Code Online (Sandbox Code Playgroud)

基本上相当于这个:

tb_MyTextBox.Text = o.Member != null ? o.Member : "default";
Run Code Online (Sandbox Code Playgroud)

这样的事情是存在的吗?我只是想象在某个地方看到这个?

.net c# asp.net null-coalescing-operator

11
推荐指数
2
解决办法
1万
查看次数

什么"??" 意思?

我正在看ASP.NET MVC 1.0生成的代码,并且想知道; 双重问号意味着什么?

// This constructor is not used by the MVC framework but is instead provided for ease
// of unit testing this type. See the comments at the end of this file for more
// information.
public AccountController(IFormsAuthentication formsAuth, IMembershipService service)
{
    FormsAuth = formsAuth ?? new FormsAuthenticationService();
    MembershipService = service ?? new AccountMembershipService();
}
Run Code Online (Sandbox Code Playgroud)

有关:

?? Null Coalescing Operator - >合并是什么意思?

c#

7
推荐指数
2
解决办法
976
查看次数