LINQ selection by type of an object

You can use the OfType Linq method for that:

var ofTypeA = collection.OfType<A>();

Regarding your unwillingness to loop throught the collection, you should keep in mind that Linq does not do magic tricks; I didn’t check the implementation of OfType, but I would be surprised not to find a loop or iterator in there.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)