您好,我无法理解为什么这段代码:
using System;
class Person
{
public Person()
{
}
}
class NameApp
{
public static void Main()
{
Person me = new Person();
Object you = new Object();
me = you as Person;
//me = (Person) you;
System.Console.WriteLine("Type: {0}", me.GetType()); //This line throws exception
}
}
抛出此异常:
未处理的异常:System.NullReferenceException:对象引用未设置为对象的实例。在 C:\Users\Nenad\documents\visual studio 2010\Projects\Exercise 11.3\Exercise 11.3\Program.cs:line 21 中的 NameApp.Main()