如何在此代码示例中获取NullReferenceException?

??? o = new ???(); Console.WriteLine("ToString() -> " + o.ToString() ); // ' Console.WriteLine("GetType() -> " + o.GetType()); //<--- NullReferenceException 

输出:

 ToString() -> Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. at System.Object.GetType() at Program.Main(String[] args) 

什么是??? 为什么o.ToString()返回string.Emptyo.GetType()会抛出NullReferenceException

注意GetType()未在???重新定义 类型。

任何Nullable

检查Gravell的例子到C#中的奇怪角点案例