I have the following class structure:
public class Fruit { } public class Apple : Fruit { }
And then I use the method from the .net structure, which gets me the property value from the class returned as an object. So,
// values will be of type List<Apple> object values = someObject.GetValue()
Now I have this object of values ββof type List, and I want to pass it to a list of type Fruit. I tried the following, but that did not work.
List<Fruit> fruits = values as List<Fruit>;
Does anyone know how to move an object to a list of its base class?
Update: at the time of casting, I do not know that the value object is of type List. I just know that this should be a list of the type that inherits from Fruit.
source share