I made a call to two different methods that returns a list both of different types. I then combined the lists into an array thus making an array of two different types of objects. Now I'm trying to loop over that array using a foreach
loop but for each item in the array, I need to access it's unique properties. Is there any way to do this?
List<TypeA> typeAVariable = SomeMethod();
List<TypeB> typeBVariable = AnotherMethod();
var arr = new ArrayList();
arr.AddRange(typeAVariable);
arr.AddRange(typeBVariable);
foreach(var item in arr)
{
if(item.typeOf == typeAVariable)
{
item.typeAVariableProperty;
}
else
{
item.typeBVariableProperty;
}
}