Goodspeed

导航

可空值类型与值类型这间的转换

int s = 5;
int? s_null;
long t;
long? t_null;

t = s; //隐式转换 S -> T
s = (int)t; //显示转换 T -> S

s_null = s; //隐式转换 S -> S?
s = (int)s_null; //显示转换 S? -> T

t_null = s_null; //隐式转换 S? -> T?
s_null = (int?)t_null; //显示转换 T? -> S?

t_null = s; //隐式转换 S -> T?
s = (int)t_null; //显示转换 T? -> S

 

posted on 2014-06-29 23:21  Goodspeed  阅读(935)  评论(0编辑  收藏  举报