我知道我可以做到这一点:
有没有一种使用条件运算符为可空变量赋值的方法?
Int32 tempInt;
Int32? exitNum;
if (Int32.TryParse(fields[13], out tempInt))
exitNum = tempInt;
else
exitNum = null;
但是为什么我不能这样做呢?
Int32 tempInt;
Int32? exitNum = Int32.TryParse(fields[13], out tempInt) ? tempInt : null;
有没有一种使用条件运算符为可空变量赋值的方法?