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

后端 未结 11 1399
猫巷女王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:05

    var animals = new List { "bird", "dog" };
    List animals= new List { "bird", "dog" };
    

    Above two are the shortest ways, please see https://www.dotnetperls.com/list

提交回复
热议问题