Would it be possible to wrap repetitive code like this:
IList<Bla1> Bla1s = (from a in Containers
where a.Right.GetType().Name.Equals("Bla1")
select
(
(Bla1) a.Right
)).Distinct().ToList<Bla1>();
into a generic construct (method?). There are many Blas (Bla1, Bla2 …). I guess Bla would represent T but I have not much experience with generics for such situations. Thanks.
If you want to test for the type and not just type name, then you can do:
Thus, your generic method could look like this:
As hvd mentioned in the comments, the code above would also return any
Rightelement that is of a type derived fromT. If your intention is to filter for typeTonly, use this instead: