当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > c# 操作符?? null coalescing operator

ASP.NET
Web服务器控件:LinkButton控件
Web服务器控件:ListBox控件
Web服务器控件:ListItem控件
Web服务器控件:Literal控件
Web服务器控件:Panel控件
Web服务器控件:PlaceHolder控件
Web服务器控件:RadioButton控件
Web服务器控件:RadioButtonList控件
Web服务器控件:BulletedList控件
Web服务器控件:Style控件
Web服务器控件:Table控件
Web服务器控件:TableCell控件
Web服务器控件:TableRow控件
Web服务器控件:TextBox控件
Web服务器控件:XML控件
Validation服务器控件:CompareValidator控件
Validation服务器控件:CustomValidator控件
Validation服务器控件:RangeValidator控件
Validation服务器控件:RegularExpressionValidator控件
Validation服务器控件:RequiredFieldValidator控件

ASP.NET 中的 c# 操作符?? null coalescing operator


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 169 ::
收藏到网摘: n/a

?? "null coalescing" operator 是c#新提供的一个操作符,这个操作符提供的功能是判断左侧的操作数是否是null,如果是则返回结果是右侧的操作数;非null则返回左侧的操作数。 我们可以看下下面的这几个示例来看看这个操作符的使用方法:
复制代码 代码如下:

string message = "Hello World";
string result = message ?? "null";
//这里的result的内容是 Hello World

再看下面的这个例子子:
复制代码 代码如下:

string message = null;
string result = message ?? "It's null";
//在这里result的内容将是 It's null