String.Split 方法有6个重载函数:
程序代码
1) public string[] Split(params char[] separator)
2) public string[] Split(char[] separator, int count)
3) public string[] Split(char[] separator, StringSplitOptions options)
4) public string[] Split(string[] separator, StringSplitOptions options)
5) public string[] Split(char[] separator, int count, StringSplitOptions options)
6) public string[] Split(string[] separator, int count, StringSplitOptions options)
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 C#中Split用法~ 2 1、用字符串分隔: 3 using System.Text.RegularExpressions; 4 string str="aaajsbbbjsccc"; 5 string[] sArray=Regex.Split(str,"js",RegexOptions.IgnoreCase); 6 foreach (string i in sArray) Response.Write(i.ToString() + "<br>"); 7 输出结果: 8 aaa 9 bbb 10 ccc 11 2、用多个字符来分隔: 12 string str="aaajbbbscccjdddseee"; 13 string[] sArray=str.Split(new char[2] {'j','s'}); 14 foreach(string i in sArray) Response.Write(i.ToString() + "<br>"); 15 输出结果: 16 aaa 17 bbb 18 ccc 19 ddd 20 eee 21 3、用单个字符来分隔: 22 string str="aaajbbbjccc"; 23 string[] sArray=str.Split('j'); 24 foreach(string i in sArray) Response.Write(i.ToString() + "<br>"); 25 输出结果: 26 aaa 27 bbb 28 ccc