I have a generic list of type 'a' which contains a generic l开发者_如何学JAVAist of type 'b', something like this:
List<A> lA = new List<A>();
List<B> lB = new List<B>();
lb.Add(new B());
lb.Add(new B());
lb.Add(new B());
lA.Add(lB);
What I want to do is build a new list of type 'b' from lA where a property on 'b' is true.
Any help with this would be greatly appreciated,
Mark
Try this one
lA.SelectMany(a => a.PropertyOfListOfBType).Where(b => b.SomeProperty).ToList()
精彩评论