字符串转数组和数组转字符串

一,字符串根据逗号,分割成数组

        string[] str;
        string str2 = "1,2,3";
        str = str2.Split(',');    

二,数组转换为以逗号分割的字符串

        string[] array = { "1", "2", "3"};
        string array1 = string.Join(",", array);

 三,字符串数组转int数组

string  fIds=“1,2,3“;
string[] SIds = fileIds.Split(',');
int[] IIds = Array.ConvertAll<string, int>(SIds, s => int.Parse(s));

四,在HTML字符串转数组

var data ="1,2";
var list= data.split(",");

五,在HTML数组转字符串

var array= new Array(0,1);
var str = array.join(",");

 

posted @ 2016-11-15 15:52  叶丶梓轩  阅读(9708)  评论(0编辑  收藏  举报