c# 如何将字符串中用","分开的数字分别存入数组中

2025-01-01 05:56:06
推荐回答(4个)
回答1:

string[] str="1,2,3,11,12,13".Split(',');这样会用,号分隔出所有字符并存入数组

回答2:

还可以使用正则表达式: 例如:string numSource = "123,212,1234,221,442,256";Regex r = new Regex ( "\\d+" );MatchCollection mc = r.Matches ( numSource );foreach ( Match m in mc ) { Console.Write ( m.Value + "\t" );}

回答3:

用Splitstring aa = "1234,234523,4324,324";
int bb= aa.Split(',');int[] ccfor(int i=0;i

回答4:

string a = "1,2,3,11,12,13";List aTemp = new List;aTemp = a.split(",").toList();