1. 程式人生 > >c#字串轉集合

c#字串轉集合

字串:string strdelId="1,2,3,4,5,6,";
去掉末尾逗號:strdelId=strdelId.TrimEnd(',');
 string[] arrID = strdelId.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);//字串轉字串集合
 int[] intArray = Array.ConvertAll<string, int>(arrID, s => int.Parse(s));//字串集合轉int型別集合