0
파생 클래스에 기본 클래스를 캐스트 할 수없는 이유는 무엇입니까? 또한, 왜 컴파일러는 이것을 잡지 못합니까?기본 클래스를 파생 클래스로 캐스팅하는 방법
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Parent p = new Parent();
Child c = (Child)p;
}
}
class Parent
{
public string Data { get; set; }
}
class Child : Parent
{
public string OtherDate { get; set; }
}
}
작동 방식. 'c.OtherDate'는 무엇을합니까? – Blorgbeard