简体   繁体   中英

How do I create and populate a List<string[]> in line? (C#)

I need to create and populate in line (is there a word for this operation?) an instance of List<string[]> . How do I do that?

var list = new List<string[]> 
{ 
    new[] { "One", "Two", "Three" },
    new[] { "Four", "Five", "Six" }
};

do you mean this?

var stringList = new List<string[]> 
{ 
    new string[] { "stringa1", "stringa2", "stringa3" }, 
    new string[] { "stringb1", "stringb2", "stringb3" },
    new string[] { "stringc1", "stringc2", "stringc3" }
};
var list_array = new List<string[]> {
   new[]{"a", "b", "c" }, new[] {"f", "g", "h"}};
var test = new List<string> { "test", "test2" };

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM