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

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

    List facts = new List() {
            "Coronavirus (COVID-19) is an illness caused by a virus that can spread from personto person.",
            "The virus that causes COVID-19 is a new coronavirus that has spread throughout the world. ",
            "COVID-19 symptoms can range from mild (or no symptoms) to severe illness",
            "Stay home if you are sick,except to get medical care.",
            "Avoid public transportation,ride-sharing, or taxis",
            "If you need medical attention,call ahead"
            };
    

提交回复
热议问题