??? o = new ???();
Console.WriteLine("ToString() -> " + o.ToString() ); //<--- Prints 'ToString() -> '
Console.WriteLine("GetType() -> " + o.GetType()); //<--- NullReferenceException
Run Code Online (Sandbox Code Playgroud)
输出:
ToString() ->
Unhandled Exception: System.NullReferenceException: Object reference not set
to an instance of an object.
at System.Object.GetType()
at Program.Main(String[] args)
Run Code Online (Sandbox Code Playgroud)
什么是类型???以及为什么o.ToString()返回string.Empty并o.GetType()抛出NullReferenceException?
注意:
GetType()未在???类型中重新定义.