110,537
社区成员
发帖
与我相关
我的任务
分享
private string[] InternalSplitKeepEmptyEntries(int[] sepList, int[] lengthList, int numReplaces, int count)
{
int startIndex = 0;
int index = 0;
count--;
int num3 = (numReplaces < count) ? numReplaces : count;
string[] strArray = new string[num3 + 1];
for (int i = 0; (i < num3) && (startIndex < this.Length); i++)
{
strArray[index++] = this.Substring(startIndex, sepList[i] - startIndex);
startIndex = sepList[i] + ((lengthList == null) ? 1 : lengthList[i]);
}
if ((startIndex < this.Length) && (num3 >= 0))
{
strArray[index] = this.Substring(startIndex);
return strArray;
}
if (index == num3)
{
strArray[index] = Empty;
}
return strArray;
}
using System;
class test
{
static void Main()
{
string a="abc a bb";
string[] b=a.Split(new string[]{" "}, StringSplitOptions.None);//以两个空格分开,放在b[]这数组里面
//循环取出数组里面的值
foreach(string s in b)
{
Console.WriteLine(s.ToString());
}
//结果:
//abc
//a
//bb
}
}