可空&LT; INT&GT;与INT? - 有什么区别? [英] Nullable<int> vs. int? - Is there any difference?
本文介绍了可空&LT; INT&GT;与INT? - 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
显然可空&LT; INT&GT;
和 INT
在价值相等的。有什么理由选择一个比其他?
可空&LT; INT&GT;一个=无效;
诠释? B =零;
A == B: // 这是真的
解决方案
没有区别。
? INT
只是简写可空&LT; INT&GT;
,这本身就是速记可空&LT;的Int32&GT;
编译code将完全哪一个您选择使用相同的。
Apparently Nullable<int>
and int?
are equivalent in value. Are there any reasons to choose one over the other?
Nullable<int> a = null;
int? b = null;
a == b; // this is true
解决方案
No difference.
int?
is just shorthand for Nullable<int>
, which itself is shorthand for Nullable<Int32>
.
Compiled code will be exactly the same whichever one you choose to use.
这篇关于可空&LT; INT&GT;与INT? - 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文