C# List<string>之间的转换

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());

 

posted @ 2019-10-16 14:13  FeelRose  阅读(18322)  评论(0编辑  收藏  举报