class Program
{
static void Main(string[] args)
{
Father objFather = new Son(); //Ok compiles
Son objSon1 = new Father(); //Comile time error : Cannot implicitly convert type
Son objSon = (Son)new Father(); //Run time error
Console.ReadLine();
}
}
class Father
{
public void Read()
{
}
}
class Daughter:Father
{
}
class Son:Father
{
}
誰でも理由を説明できますか? そして、記憶の中で何が起こっていますか?