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類型集合
發佈了54 篇原創文章 · 獲贊 0 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章