1. 程式人生 > >C# List泛型轉換,int,string 轉字元,轉陣列各種型別的轉換

C# List泛型轉換,int,string 轉字元,轉陣列各種型別的轉換

List轉字串

2

List<string> List = new List<string>();

string strArray = string.Join(",", List);

字串轉List

1

2

string str = "2,4,4,4";

List<string> List=new List<string> (str.Split(','))

字元陣列轉Int陣列

1

2

string

 str = "2,4,4,4";

int[] list = Array.ConvertAll<stringint>(str.Split(','), s => int.Parse(s));

List<string>字串轉Int陣列

1

2

3

List<string> List = new List<string>();

string strArray = string.Join(",", List);

int[] list = Array.ConvertAll<

stringint>(strArray.Split(','), s => int.Parse(s));