Say I have three classes that look like this:
abstract class Fruit
{
public string name { get; set; }
}
class Apple : Fruit
{
public int redness { get; set; }
}
class Pear : Fruit
{
public int size { get; set; }
}
And somewhere else I have:
List<Fruit> delicious_things = new List<Fruit>{
new Pear(){}
new Apple(){}
}
How do I access, as an example the pear.size from delicious_things?
If I know already that Pear is delicious_things[0], I could do: delicious_things[0].size, but that doesn't seem to work.
What am I missing? Thanks in advance!