可空类型(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;

 

 

 

相关文章:

  • 2021-08-01
  • 2022-12-23
  • 2022-12-23
  • 2021-06-01
  • 2021-05-31
  • 2021-07-28
猜你喜欢
  • 2021-09-07
  • 2021-11-20
  • 2022-12-23
  • 2022-01-06
  • 2021-12-29
  • 2021-06-06
相关资源
相似解决方案