So this is what i'm trying to achieve, is there an elegant way to do this?
public class item
{
}
public class A : item
{
public int a;
}
public class B : item
{
public string b;
}
public class example
{
A classA = new A();
B classB = new B();
item[] itemArray = {classA, classB}
foreach(item i in itemArray)
{
// get int a if item i is ofType A
// get string b if item i is ofType B
}
}
I've tried overriding but that forces me to create virtual fields of both a and b in the base class. There has to be a better way.