C# List泛型转换,int,string 转字符,转数组

List转字符串

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

字符串转List

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数组

List<string> List = new List<string>();
string strArray = string.Join(",", List);
int[] list = Array.ConvertAll<string, int>(strArray.Split(','), s => int.Parse(s));

 

posted @ 2016-01-26 18:15  狂歌  阅读(3649)  评论(0编辑  收藏  举报