I am working with C # and I have the following
List<List<UserObj>> obj;
How to get the internal list ( List<UserObj> ) of an obj object?
List<UserObj>
Thanks.
There is no internal list - there are many of them.
You can get specific, for example: obj[0] .
obj[0]
Alternatively, you can combine the contents of all lists into one long list:
var result = obj.SelectMany(x => x).ToList();
List<UserObj> users = obj[myindex];
or
foreach(List<UserObj> users in obj) { foreach(UserObj user in users) { // now we have an individual user from our list of lists } }
Am I simplifying this?
foreach( var innerList in outerList ) { foreach( var item in innerList ) { // do whatever } }
This is a list of listings. You can list obj list. Each item has a List<UserObj> value.
obj
foreach (List<UserObj> innerList in obj) { // do something with innerlist }