如果子类的实例被强制转换回继承的类,存储在子类字段中的数据会发生什么情况?这在内存中是如何工作的?
public abstract class AchievementNode : PrioritizedData
{
public enum NodeTypes
{
NONE = 0x0,
HEAD = 0x1,
TAIL = 0x2,
TYPE = 0x4,
DATA = 0x8,
LEVEL = 0x16,
GLOBAL = 0x32
}
public NodeTypes nodeType;
public virtual AchievementNode Init(NodeTypes type, params int[] enumData)
{
nodeType = type;
return this;
}
}
public class AchievementTypeNode : AchievementNode
{
public enum AchievementTypes {TIME,COMPLETION,UNLOCK,SOCIAL,ACTION};
public AchievementTypes AchievementType;
public override AchievementNode Init(AchievementNode.NodeTypes type)
{
base.Init(type);
return (AchievementNode)this;
}
}