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://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 View Code 2 C#中Split用法~ 3 1、用字符串分隔: 4 using System.Text.RegularExpressions; 5 string str="aaajsbbbjsccc"; 6 string[] sArray=Regex.Split(str,"js",RegexOptions.IgnoreCase); 7 foreach (string i in sArray) Response.Write(i.ToString() + "<br>"); 8 输出结果: 9 aaa 10 bbb 11 ccc 12 2、用多个字符来分隔: 13 string str="aaajbbbscccjdddseee"; 14 string[] sArray=str.Split(new char[2] {'j','s'}); 15 foreach(string i in sArray) Response.Write(i.ToString() + "<br>"); 16 输出结果: 17 aaa 18 bbb 19 ccc 20 ddd 21 eee 22 3、用单个字符来分隔: 23 string str="aaajbbbjccc"; 24 string[] sArray=str.Split('j'); 25 foreach(string i in sArray) Response.Write(i.ToString() + "<br>"); 26 输出结果: 27 aaa 28 bbb 29 ccc