当我在 int 或 DateTime 属性上调用 GetType 时,我得到了预期的结果,但在字符串属性上,我得到了 NullReferenceException (?) :
private int PropInt { get; set; }
private DateTime PropDate { get; set; }
private string propString { get; set; }
WriteLine(PropInt.GetType().ToString()); // Result : System.Int32
WriteLine(PropDate.GetType().ToString()); // Result : System.DateTime
WriteLine(propString.GetType().ToString()); // Result : NullReferenceException (?!)
有人能解释一下是怎么来的吗?string-prop 与 int-prop 有何不同?