可空类型(Nullbale Types)
1. 可空类型是System.Nullbale<T>
2. 可空类型可以表示其基础类型正常范围内的值,再加上一个null值
例如:Nullable<Int32>
简化写法版:Nullable<int> n=null;
int? n=null;
3. System.Nullbale<T>结构
public bool HasValue {get;}是否有值
public T Value {get;}
public T GetValueOrDefault()
4. 使用??运算符分配默认值。
int? x=null;
int y=x?? -1;
转载于:https://www.cnblogs.com/hainange/archive/2007/09/03/6153347.html
最后
以上就是幸福小天鹅最近收集整理的关于.Net 2.0 新功能:可空类型(Nullbale Types)的全部内容,更多相关.Net内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复