C# ??符号
2015-11-27 14:52
447 查看
static void Main(string[] args) { string strA = String.Empty; string strB = String.Empty; strA = null; strB = "strB"; /** * 如果??左边的strA值为String.IsNullOrWhiteSpace则StrC=strB * 如果??右边的strB值为String.IsNullOrWhiteSpace则StrC=strA */ string StrC = strA ?? strB; Console.WriteLine(StrC); strB = null; strA = "strA"; Console.WriteLine(strA ?? strB); strB = String.Empty; strA = "No Empty"; string a = strA ?? strB; Console.WriteLine(a == null ? "null" : a); Console.ReadLine(); }
输出
相关文章推荐
- C#开发学习(Visual Studio的安装与使用)
- [原创]C#按比例缩放窗体控件及字体
- POI操作Excel详解---HSSF和XSSF两种方式
- 动态调用WebService(C#) (非常实用)转载
- C#调用Mail发送QQ邮件
- C#_event_事件
- 客户端(C#)调用CXF搭建的webservice的出现一些问题记录
- C# Attribute(中)——Attribute本质论
- C#操作word文档
- C#拾遗-接口与抽象类
- C# Attribute (上)——Attribute初体验
- C#3.0之神奇的Lambda表达式和Lambda语句
- 【NCRE】——c#判断ppt中的艺术字
- c# 类中使用ResolveUrl
- C#里WinForm开发中如何实现控件随窗体大小的改变而自动适应其改变
- C#比较二个数组并找出相同或不同元素的方法
- C#Chart属性
- C#实现XSL转换的方法
- C# 托盘程序 实例 双击显示窗体,最小化到托盘
- C# 托盘程序