可空< INT>与INT? - 有什么区别? [英] Nullable<int> vs. int? - Is there any difference?

查看:123
本文介绍了可空< INT>与INT? - 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

显然可空< INT> INT 在价值相等的。有什么理由选择一个比其他?

 可空< INT>一个=无效;
诠释? B =零;
A == B: // 这是真的
 

解决方案

没有区别。

INT 只是简写可空< INT> ,这本身就是速记可空<的Int32>

编译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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆