Reputation: 163
i have the following setup;
public abstract class StageObject
{
}
public class StageImage : StageObject
{
public int Image;
}
public class StageStrip : StageObject
{
public int Strip;
}
i do the following;
StageList = new List<StageObject>();
StageList.Add(new StageStrip());
StageList.Add(new StageImage());
i would love to be able to cast the array element as it's concrete type like this but i get an error;
(StageStrip) StageList[0].Strip = 2;
the only way i can do this is to create a temporary variable and cast it to the array. is there a way i can do it without creating the temporary variable?
Upvotes: 0
Views: 457