首页 > 代码库 > 可空值类型与值类型这间的转换

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

int s = 5;int? s_null;long t;long? t_null;t = s; //隐式转换 S -> Ts = (int)t; //显示转换 T -> Ss_null = s; //隐式转换 S -> S?s = (int)s_null; //显示转换 S? -> Tt_null = s_null; //隐式转换 S? -> T?s_null = (int?)t_null; //显示转换 T? -> S?t_null = s; //隐式转换 S -> T?s = (int)t_null; //显示转换 T? -> S