C# List泛型轉換,int,string 轉字符,轉數組

List轉字符串數組

List<string> List = new List<string>();
string strArray = string.Join(",", List);

字符串轉Listblog

string str = "2,4,4,4";
List<string> List=new List<string> (str.Split(','))

字符數組轉Int數組字符串

string str = "2,4,4,4";
int[] list = Array.ConvertAll<string, int>(str.Split(','), s => int.Parse(s));

List<string>字符串轉Int數組string

List<string> List = new List<string>();
string strArray = string.Join(",", List);
int[] list = Array.ConvertAll<string, int>(strArray.Split(','), s => int.Parse(s));
相關文章
相關標籤/搜索