I have 2 entities:
class A {
...
}
class B {
IEnumerable<B> bs;
}
I have array of A’s and I need to get all the B’s in one IEnumerable. I can do:
IEnumerable<A> as=....;
IEnumerable<IEnumerable<B>> bss=as.Select(x=>x.bs);
IEnumerable<B> all=null;
foreach (IEnumerable<B> bs is bss) {
if (all==null) { all=bs; }
else { all=all.Contact(bs); }
}
I want to know if there is shorter way to do this.
Thanks
You can Use SelectMany that will concatenate all the IEnumerables together