Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get inner list from list of list C#

Tags:

c#

I am working with C# and I have a following

List<List<UserObj>> obj;

How do I get the inner list (List<UserObj>) of obj?

Thanks.

like image 1000
Tony Avatar asked Nov 30 '22 09:11

Tony


1 Answers

There isn't an inner list - there are many of them.

You can get a specific one, for example: obj[0].

Alternatively you can concatenate the contents of all the lists into one long list:

var result = obj.SelectMany(x => x).ToList();
like image 199
Mark Byers Avatar answered Dec 02 '22 23:12

Mark Byers