-2

Is there a way to place 3 List strings into another List<>?

Starting with:

List<???> listTableNames = new List<???>();
List<string> liststTable1 = new List<string>();
List<string> liststTable2 = new List<string>();
List<string> liststTable3 = new List<string>();
listTableNames.Add(liststTable1);
listTableNames.Add(liststTable2);
listTableNames.Add(liststTable3);
ttom
  • 985
  • 3
  • 12
  • 21
  • 3
    Are you asking how to make a list where each element is a list of strings? That's `List>`. If that's not what you're asking, can you clarify the question? – Eric Lippert Apr 26 '21 at 23:30

2 Answers2

1

Hope this help you , using AddRange method:

List<string> listTableNames = new List<string>();
List<string> liststTable1 = new List<string>();
List<string> liststTable2 = new List<string>();
List<string> liststTable3 = new List<string>();

listTableNames.AddRange(liststTable1);
listTableNames.AddRange(liststTable2);
listTableNames.AddRange(liststTable3);

Online demo

AziMez
  • 2,014
  • 1
  • 6
  • 16
1

Eric Lippert provided the answer in the comments.

List<List<string>> listTableNames = new List<List<string>>();

This works.

ttom
  • 985
  • 3
  • 12
  • 21