I have a few ObservableCollections with different object models, all inheriting from the same base model. For example:
class Food { }
class Pizza : Food { }
class Rice : Food { }
class Spaghetti : Food { }
and an ObservableCollection for each one:
ObservableCollection<Pizza> pizzaOC;
ObservableCollection<Rice> riceOC;
ObservableCollection<Spaghetti> spOC;
Then I have a method which has an ObservableCollection<Food>
parameter, like so:
private bool CheckFood(ObservableCollection<Food> foodItems)
{
// stuff here
}
The problem comes when I try to do the calls :
CheckFood(pizzaOC);
CheckFood(riceOC);
//...
Is there any way I can call a single method, but passing different types of ObservableCollections? And also, is there a way to find out in the method, which OC type has been passed?