首页 > 代码库 > c# List<string>和List<int>互相转换

c# List<string>和List<int>互相转换

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>和List<int>互相转换