C#中“?”的几种用途
原创-
第一种:三元运算(最经常用的)
用法:string a = a == "1" ? a : "2" -
第二种:可null类型修饰符 (正常int大家都知道,是不允许为null的,不过可以通过?进行修饰来让它可null)
int a = null;//报错
int? b = null;//可正常编译
-
空合并运算符
string a = null; string b = "文字"; //这里表示,如果a为null,就返回b(??左边为null则返回??右边,??左边不为null则返回??左边); string c = a ?? b;
版权声明
所有资源都来源于爬虫采集,如有侵权请联系我们,我们将立即删除
上一篇:C#一维数据函数为层级计算 下一篇:Winfrom中的保存和反选
相关文章
最新文章
- 0.05ms 往返:localhost 为什么不能直接当网站? 4小时前
- Fornax's Guide to Fast Ethernet 4小时前
- Possibly leaked NSA Cyberattack tool behind attacks (2017) 5小时前
- Steve Wozniak on Writing Apple Integer Basic 5小时前
- PayByPhone is stealing $50M/year from their users 5小时前
- Grand Theft Auto 6: A Landmark Achievement That Redefines a Console Generation 5小时前
- Research Acceleration: The Jagged Frontier 6小时前
- Google Embraces Geothermal Technology to Vaporize Rock for Clean Power 7小时前
- Microsoft's Agent Framework PyPI package compromised to steal credentials 8小时前
- Nvidia's Seven Billionaires Have Lost a Third of Their Wealth 8小时前
itfan123


