Union multiple number of lists in C#

后端 未结 2 534
猫巷女王i
猫巷女王i 2020-12-18 21:18

I am looking for a elegant solution for the following situation:

I have a class that contains a List like

class MyClass{ 
...
 public List

        
2条回答
  •  星月不相逢
    2020-12-18 21:39

    You should have a look at SelectMany. Something like this should generate your "flat" list:

    MyClassList.SelectMany(b => b.SomeOtherClasses)
    

    It will return a IEnumerable which you can filter/process further.

提交回复
热议问题