c#中这样一个判断条件:if (IsTa ?? false)
我试了一下只有IsTa 为true的情况下,才会执行这个分支,这是什么意思?
我试了一下只有IsTa 为true的情况下,才会执行这个分支,这是什么意思?
解决方案 »
- 未能加载文件 System.Data.SQLite
- WINform里面怎么做树状列表 的菜单
- 无法将位于索引 78 处的字节 [92] 由指定的代码页转换为 Unicode
- 如何让程序在系统启动的时候就启动?
- datagridview 问题
- 工作流添加到另一项目中 散分,来顶呀
- system.net.mail 发送邮件 高分求解
- 我想创建自定义的项目模板 和自定义类文件模板,那位高手做过给你思路!!!
- 有谁知道csdn论坛c#版块前几天的哪个提供C#案例下载的ftp ?????????
- 做一个统计图片的点击率,和标题的点击率,最好给我一个源码看一下,小弟在线等,只有这一点分了,请多多包涵
- 求大侠指教
- 新浪博客自动发博文POST不过去
{
static int? GetNullableInt()
{
return null;
} static string GetStringValue()
{
return null;
} static void Main()
{
// ?? operator example.
int? x = null; // y = x, unless x is null, in which case y = -1.
int y = x ?? -1; // Assign i to return value of method, unless
// return value is null, in which case assign
// default value of int to i.
int i = GetNullableInt() ?? default(int); string s = GetStringValue();
// ?? also works with reference types.
// Display contents of s, unless s is null,
// in which case display "Unspecified".
Console.WriteLine(s ?? "Unspecified");
}
}参考:
http://msdn.microsoft.com/en-us/library/ms173224.aspx
等同于
if(b == null)
a = c;
else
a = b;
2. IsTa 为false时,IsTa ?? false ---》 false
3. IsTa为true时,IsTa ?? false的结果就是IsTa的值,即为true,所以会去执行{}中的内容
IsTa为null时,返回false;不为null时,返回IsTa
等价于
isnull==null?"show":isnull