snippetcsharpCritical
How to initialize a list of strings (List<string>) with many string values
Viewed 0 times
withhowmanyinitializestringsliststringvalues
Problem
How is it possible to initialize (with a C# initializer) a list of strings? I have tried with the example below but it's not working.
List optionList = new List
{
"AdditionalCardPersonAddressType","AutomaticRaiseCreditLimit","CardDeliveryTimeWeekDay"
}();Solution
List mylist = new List(new string[] { "element1", "element2", "element3" });Code Snippets
List<string> mylist = new List<string>(new string[] { "element1", "element2", "element3" });Context
Stack Overflow Q#3139118, score: 561
Revisions (0)
No revisions yet.