110,502
社区成员
发帖
与我相关
我的任务
分享
string a = @"11111111122222222222233333333333344444444444445555555555577777888888899999999991111111111112222222222222215555555555848888888888";
a += "1111111111111222222222222222223333333333333333333344444444444456565656565656565656878787899999999994555555555555";
int iNum = 100;
int iCouLength = a.Length / iNum;
string[] test = new string[iCouLength + 1];//因为有不等于100长度的情况
int j = 0;
for (int i = 0; i <= iCouLength; i++)
{
if (i == iCouLength)
test[i] = a.Substring(i * iNum);//不等于100个长度的情况
else
test[i] = a.Substring(i * iNum, iNum);//等于100的情况。
}
string a = "111112222223333334444444445555555555555556666666666666667777777777777777788888888888888888888888888888888999999999999999999999999991111122222233333344444444455555555555555566666666666666677777777777777777888888888888888888888888888888889999999999999999999999999911111222222333333444444444555555555555555666666666666666777777777777777778888888888888888888888888888888899999999999999999999999999111112222223333334444444445555555555555556666666666666667777777777777777788888888888888888888888888888888999999999999999999999999991111122222233333344444444455555555555555566666666666666677777777777777777888888888888888888888888888888889999999999999999999999999911111222222333333444444444555555555555555666666666666666777777777777777778888888888888888888888888888888899999999999999999999999999111112222223333334444444445555555555555556666666666666667777777777777777788888888888888888888888888888888999999999999999999999999991111122222233333344444444455555555555555566666666666666677777777777777777888888888888888888888888888888889999999999999999999999999911111222222333333444444444555555555555555666666666666666777777777777777778888888888888888888888888888888899999999999999999999999999111112222223333";
Regex reg = new Regex(".{100}");
MatchCollection mct = reg.Matches(a);
foreach (Match m in mct)
{
Console.WriteLine(m.Value);
}
Console.Read();
Int32 i, j, k;
List<string> lst=new List<string>();
string a = "123456789";
i = 2; //i:每组几个 //j:被截走的长度 //k:循环几次
k = a.Length % i == 0 ? a.Length / i : a.Length / i + 1;
j = 0;
for (int y = 0; y < k; y++) //此处出错····
{
a = a.Substring(j, i);
lst.Add(a);
j += i;
}