Count number of element in List>

前端 未结 4 1306
野性不改
野性不改 2021-02-12 07:53

I have a List>. How can I count all the elements in this as if it was a single List in the fastest way?

So far I h

4条回答
  •  醉话见心
    2021-02-12 08:54

    To count all the elements in all the lists in the list, you could use the aggregating operators:

    int count = listOfLists.Sum(l => l.Distinct().Count());
    

提交回复
热议问题