Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# What does List<List<string>> mean?

Tags:

c#

What is List<List<string>> and how do I get the data out (as Strings)?

like image 348
Cocoa Dev Avatar asked Apr 27 '26 02:04

Cocoa Dev


1 Answers

It's a list of lists of strings. Each element of the "outer" list is a list of strings. The simplest way to "flatten" the list is to use LINQ:

var flattened = listOfLists.SelectMany(list => list);

foreach (var value in flattened)
{
    Console.WriteLine(value);
}
like image 195
Jon Skeet Avatar answered Apr 28 '26 15:04

Jon Skeet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!