// 使用扩展方法做
public static string[] SplitExt(this string sourceString, string splitString)
{
    List
<string> arrayList = new List<string>();
    
string s = string.Empty;
    
while (sourceString.IndexOf(splitString) > -1)
    {
        s 
= sourceString.Substring(0, sourceString.IndexOf(splitString));
        sourceString 
= sourceString.Substring(sourceString.IndexOf(splitString) + splitString.Length);
        arrayList.Add(s);
    }
    arrayList.Add(sourceString);
    
return arrayList.ToArray();
}

// 使用普通方法做
public static string[] StringSplitExt(string sourceString, string splitString)
{
    List
<string> arrayList = new List<string>();
    
string s = string.Empty;
    
while (sourceString.IndexOf(splitString) > -1)
    {
        s 
= sourceString.Substring(0, sourceString.IndexOf(splitString));
        sourceString 
= sourceString.Substring(sourceString.IndexOf(splitString) + splitString.Length);
        arrayList.Add(s);
    }
    arrayList.Add(sourceString);
    
return arrayList.ToArray();
}

相关文章:

  • 2021-12-27
  • 2021-11-29
  • 2021-07-18
  • 2021-12-04
  • 2021-08-27
猜你喜欢
  • 2021-05-18
  • 2021-08-27
  • 2022-02-08
  • 2021-09-23
  • 2022-12-23
  • 2021-07-08
相关资源
相似解决方案