C# 如何像列表中的行一样放置数组<;字符串>;

C# 如何像列表中的行一样放置数组<;字符串>;,c#,arrays,list,C#,Arrays,List,如何像列表中的行一样放置数组 例如: string[] Myarray = new string[] {"A","B", "C"}; List<string> MyList = new List<string>() { Myarray[0], Myarray[1], Myarray[2] }; string[]Myarray=新字符串[]{“A”、“B”、“C”}; List MyList=new List(){Myarray[0],Myarray[1],Myarr

如何像列表中的行一样放置数组

例如:

 string[] Myarray = new string[] {"A","B", "C"};
 List<string> MyList = new List<string>() { Myarray[0], Myarray[1], Myarray[2] };
string[]Myarray=新字符串[]{“A”、“B”、“C”};
List MyList=new List(){Myarray[0],Myarray[1],Myarray[2]};
List strings=Arrays.asList(新字符串[]{“一”、“二”、“三”});
这是数组的列表视图,列表部分不可修改,不能添加或删除元素。但时间复杂度为O(1)

如果需要可修改的列表,请执行以下操作:

List<String> strings = 
     new ArrayList<String>(Arrays.asList(new String[]{"one", "two", "three"}));
列表字符串=
新的ArrayList(Arrays.asList(新字符串[]{“一”、“二”、“三”}));

这将把源数组中的所有元素复制到一个新列表中(复杂性:O(n))

MyList=Myarray.ToList()你的
列表
需要和你放进去的东西类型相同。试试看这是.NET/BCL吗
Arrays.asList
ArrayList
?@JeppeStigNielsen我是新手,我的类只使用过javascript和BlueJ。我知道它是什么,我相信它不是BCL,而是我在课堂上的一个项目中是如何做到的。我不确定它是不是FCL,但我没有多年的经验,所以我不知道。我还试图在帮助他人的同时了解javascript和BlueJ。由于询问者使用了标签
[c#]
,我认为javascript或BlueJ/Java与他的问题无关。我最后一句话的意思是,在尝试学习javascript和BlueJ的同时,我也在业余时间学习c#
List<String> strings = 
     new ArrayList<String>(Arrays.asList(new String[]{"one", "two", "three"}));