我可以通过以下方式将List<string>
添加到List<List<string>>
数组中:
List<string> first = new List<string> { "one", "two", "three" };
List<string> second = new List<string> { "four", "five", "six" };
List<List<string>> list_array = new List<List<string>> { first, second };
现在我需要创建几个填充有数据库记录的列表,并将这些列表添加到 List<List<string>>
数组中:
List<List<string>> array_list;
while (dr.Read())
{
string one = dr["Row1"].ToString();
string two = dr["Row2"].ToString();
List<string> temp_list = new List<string> { one, two };
//Here I need to add temp_list to array_list
}