How exactly does this work?
If I have this base class
public class BaseClass
{
public int Value1 { get; set; }
public int Value2 { get; set; }
public BaseClass SimpleClone()
{
BaseClass result = new BaseClass();
result.Value1 = this.Value1;
result.Value2 = this.Value2;
return result;
}
}
And this child class
public class DerivedClass : BaseClass
{
public bool Value3 { get; set; }
public DerivedClass()
{
Value3 = true;
}
}
How can I downcast BaseCast.SimpleClone()
into anotherObj
? What would happen to Value3?
While knowing what happens is good, I am also interested in why it works this way.