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<string> optionList = new List<string>
{
    "AdditionalCardPersonAddressType","AutomaticRaiseCreditLimit","CardDeliveryTimeWeekDay"
}();

13 s
13

Just remove () at the end.

List<string> optionList = new List<string>
            { "AdditionalCardPersonAdressType", /* rest of elements */ };

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *