How to print a list of lists in C#

1 Answer

0 votes
using System;
using System.Collections.Generic;

class Program
{
    static void Main() {
        List<List<string>> list_list = new List<List<string>>();
        
        list_list.Add(new List<string> { "a", "b", "c", "d", "e", "f", "g" });
        list_list.Add(new List<string> { "c#", "c++", "c", "java", ".NET" });
        list_list.Add(new List<string> { "php", "python" });

        foreach (List<string> subList in list_list) {
            foreach (string item in subList) {
                Console.WriteLine(item);
            }
            Console.WriteLine();
        }
    }
}



/*
run:

a
b
c
d
e
f
g

c#
c++
c
java
.NET

php
python

*/

 



answered Mar 10, 2021 by avibootz

Related questions

1 answer 125 views
125 views asked Mar 10, 2021 by avibootz
1 answer 187 views
1 answer 250 views
1 answer 240 views
240 views asked Mar 10, 2021 by avibootz
1 answer 171 views
...