Since you have a List<object>
that actually contains List<List<Player>>
and you want to get a list of players in one big list. Unfortunately for some external reason you are unable to change the API to give you sensibly typed data, you need to go through a couple of hoops. So given this:
List<object> players = <snip>;
You can extract a list of Player
objects using SelectMany
with some casting:
var allPlayers = players
.SelectMany(list => (List<object>)list)
.Cast<Player>();
0
solved How to LINQ List> and flatten it using SelectMany?