Using Linq to group by object type
Posted on 2011-03-01
I have a list of objects that derive from a common base class i.e. List<BaseObject>. Contained within this list are subclasses ObjectA, ObjectB, ObjectC. There can be many instances of these sub classes contained in List<BaseObject> i.e. ObjectA has 4 instances, ObjectB has 3 instances, and ObjectC has 5 instances. I have the following question, is there a way either using linq or some other method to group each sub class instance into separate lists for example List<ObjectA>, List<ObjectB> and List<ObjectC> and then execute a common method called getIDs(). This execution ideally would need to happen in parallel.