How to initialize a list of strings (List) with many string values

后端 未结 11 1333
猫巷女王i
猫巷女王i 2020-11-28 18:40

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 opt         


        
11条回答
  •  南方客
    南方客 (楼主)
    2020-11-28 19:01

    You haven't really asked a question, but the code should be

    List optionList = new List { "string1", "string2", ..., "stringN"}; 
    

    i.e. no trailing () after the list.

提交回复
热议问题