什么是" ??"运营商? [英] What is the "??" operator for?
本文介绍了什么是" ??"运营商?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道 ??在
迹象code。这是什么呢?我如何使用它? C#
什么 INT?
?它是一个可空INT?
参见:
<一个href=\"http://stackoverflow.com/questions/770186/null-coalescing-operator-what-does-coalescing-mean\">??空合并运算符 - >是什么意思凝聚
块引用>解决方案这就是所谓的空合并运算符和作品是这样的:
而不是做的:
诠释?数=无效;
INT结果=号== NULL? 0:数;您可以现在只是做:
INT结果= ??号0;
I was wondering about
??
signs inC#
code. What is it for? And how can I use it?What about
int?
? Is it a nullable int?See also:
解决方案It's called the "null coalescing operator" and works something like this:
Instead of doing:
int? number = null; int result = number == null ? 0 : number;
You can now just do:
int result = number ?? 0;
这篇关于什么是&QUOT; ??&QUOT;运营商?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文