11
01/12
C#中值为NULL时计算出错处理方法
static void Main(string[] args) { Nullable<int> x1 = GetNullableType();//可空结构 if (x1.HasValue)//判断是否有值,也就是是否为null { Console.WriteLine("x1有值得{0}", x1.Value); //获取value } else { Console.WriteLine("x1无值."); } int? x2 = 0; int? x3 = x1 + x2;//两个运算数据一个为null则结果为null int y1 = x3 ?? 1;//结合运算符,如果??前的数据...