如何初始化一个C#字符串列表(列表<串GT;)与许多字符串值 [英] How to initialize a C# string list (List<string>) with many string values
本文介绍了如何初始化一个C#字符串列表(列表<串GT;)与许多字符串值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这怎么可能初始化(用C#初始化)字符串列表?我曾尝试与下面的例子,但它不工作
列表<串GT; optionList =新的List<串GT;
{
AdditionalCardPersonAdressType,AutomaticRaiseCreditLimit,CardDeliveryTimeWeekDay
}();
解决方案
列表<字符串> MYLIST =新的List<串GT(新的字符串[] {中element1,在element2,元素3});
我要被担心在OP名单的一些细节切莫...:)
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>
{
"AdditionalCardPersonAdressType","AutomaticRaiseCreditLimit","CardDeliveryTimeWeekDay"
}();
解决方案
List<string> mylist = new List<string>(new string[] { "element1", "element2", "element3" });
I shall refrain from being worried about some of the details in the OP's list... :)
这篇关于如何初始化一个C#字符串列表(列表<串GT;)与许多字符串值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文