C#中字符串分割
有时我们需将一个字符串用另一个字符串来分割成字符串字组。而C#中string.split只提供用char来分割。怎么办?
用的时候直接调用第一个函数。

 

 strSplit)
{
string[] strtmp = new string[1];
int index = strSource.IndexOf(strSplit,0);
if(index<0)
{
strtmp[
0] = strSource;
return strtmp;
}
else
{
strtmp[
0] = strSource.Substring(0,index);
return StringSplit(strSource.Substring(index+strSplit.Length),strSplit,strtmp);
}
}
[] attachArray)
{
string[] strtmp = new string[attachArray.Length+1];
attachArray.CopyTo(strtmp,
0);

int index = strSource.IndexOf(strSplit,0);
if(index<0)
{
strtmp[attachArray.Length]
= strSource;
return strtmp;
}
else
{
strtmp[attachArray.Length]
= strSource.Substring(0,index);
return StringSplit(strSource.Substring(index+strSplit.Length),strSplit,strtmp);
}
}

 


相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-12
  • 2021-07-30
  • 2021-12-29
  • 2022-01-10
  • 2021-09-24
  • 2021-08-06
  • 2021-11-15
  • 2021-12-23
相关资源
相似解决方案