C#List转字符串,字符串转List,字符数组转Int数组, List<string> 转换为 List<int> 类型

List转字符串

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



字符串转List

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



字符数组转Int数组

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



List<string>字符串转Int数组

 
01
02
03
List<string> List = new List<string>();
string strArray = string.Join(",", List);
int[] list = Array.ConvertAll<string, int>(strArray.Split(','), s => int.Parse(s));
 
 
List<string> 转换为 List<int> 类型:
List<int> tempNum = tempStr.Select(int.Parse).ToList();
posted @ 2021-03-07 10:40  石衣_2014  阅读(472)  评论(0编辑  收藏  举报