C# List之间的转换

List<string> 转换为 string

List<string> list = new List<string>();
list.Add("a");
list.Add("b");
list.Add("c");
string str = string.Join("  ", list.ToArray());	//用空格串联字符串
结果:a b c 

 List<string> 转 List<int>

var list = (new[]{"1","2","3"}).ToList();
var newlist = list.Select<string,int>(x =>Convert.ToInt32(x));

 List<int> 转 List<string>

List<int> list = new List<int>(new int[] { 1,2,3 } );
List<string> newList = list.ConvertAll<string>(x => x.ToString());

 

C# List<string>之间的转换

上一篇:c#获取Mac地址最全方法


下一篇:Windows服务中读取网络映射路径无法访问