| 下面的这篇文章,介绍了Split方法的各种重载的应用,并有例子,字符串切割的话可以看看+ L2 S6 U* y( _* r$ i http://www.itwis.com/html/net/c/20100506/8234.html
 # X' e5 Q& q* h! ~2 ?2 c
 4 ]% t5 H7 V8 w! O' x程序代码
 ^8 Q) T) s" T/ p1) public string[] Split(params char[] separator), I/ k9 B5 A3 C6 }8 E
 2) public string[] Split(char[] separator, int count)9 S* k7 i( A. m! b9 k' z
 3) public string[] Split(char[] separator, StringSplitOptions options)5 ~) D7 d1 \# C: Q
 4) public string[] Split(string[] separator, StringSplitOptions options)
 # T! f/ l' r: U. ~- W& Q5) public string[] Split(char[] separator, int count, StringSplitOptions options)
 * b" N; H8 V0 S/ u) l1 _: S6) public string[] Split(string[] separator, int count, StringSplitOptions options)
 4 k6 ?; z: k) y
 / N2 l; v0 y/ P; x' `; I# y下边我们通过一些实例来说明下怎么使用(以下string words = "1,2.3,,4";):
 # J' a' P4 \3 z. b4 T# w8 N7 ^
 ) [$ S8 J3 @9 I$ w1. public string[] Split(params char[] separator). [, q! ~! l5 _. O
 
 9 X- T. }1 {3 _9 L. H# K8 B+ j 程序代码* |( M& n, E( s8 ?' `* a
 string[] split = words.Split(new Char[] { ',' });//返回:{"1","2.3","","4"}
 / {9 @( s4 N2 h% u" ], Q: M: Mstring[] split = words.Split(new Char[] { ',', '.' });//返回:{"1","2","3","","4"}1 y$ k  U) a+ |2 g. g8 h( U
 & U* X7 F  l: N# Y2 k- Y: x
 2. public string[] Split(char[] separator, int count)
 + V( i! O, a, x8 ^  H; b  G+ F3 G  {- ]+ k: i; R, A! m6 q2 ^/ S
 程序代码& J: S, k  O: D' s* [$ ~) }7 o
 string[] split = words.Split(new Char[] { ',', '.' }, 2);//返回:{"1","2.3,,4"}
 1 e# i) n- g1 o8 ~' m  L0 i: zstring[] split = words.Split(new Char[] { ',', '.' }, 6);//返回:{"1","2","3","","4"}
 2 R( e. S- H+ E8 W! r  D9 v0 O: k3 \
 3. public string[] Split(char[] separator, StringSplitOptions options)1 u/ q( \* W. n
 7 H) b$ ~' @( `0 k! K: L7 {. l
 程序代码4 \4 E; K. z. P+ p$ T! G
 string[] split = words.Split(new Char[] { ',', '.' }, StringSplitOptions.RemoveEmptyEntries);//返回:{"1","2","3","4"} 不保留空元素8 x) p; v) T5 r
 string[] split = words.Split(new Char[] { ',', '.' }, StringSplitOptions.None);//返回:{"1","2","3","","4"} 保留空元素
 & z# ]4 w+ a9 x' z2 k/ ~
 3 M8 L7 e$ m+ C' t  b9 z5 ~4. public string[] Split(string[] separator, StringSplitOptions options)
 1 D; C& ~; R3 G) Y& G# g9 |4 w% _- n
 程序代码4 G1 f1 m9 t! o+ ?8 L: X: G
 string[] split = words.Split(new string[] { ",", "." }, StringSplitOptions.RemoveEmptyEntries);//返回:{"1","2","3","4"} 不保留空元素% L: d( ~% k! b9 |1 o+ n, E
 string[] split = words.Split(new string[] { ",", "." }, StringSplitOptions.None);//返回:{"1","2","3","","4"} 保留空元素& |* f+ Z" F' s8 y, M: u' X% _
 
 1 p; F7 }. I/ q5. public string[] Split(char[] separator, int count, StringSplitOptions options)/ {  k7 u; k1 R- F/ k7 e5 B/ v. Q
 , r  c# S! G% d! @+ a
 程序代码: q' m7 R/ }2 U' h6 j; K  P
 string[] split = words.Split(new Char[] { ',', '.' }, 2, StringSplitOptions.RemoveEmptyEntries);//返回:{"1","2.3,,4"} 不保留空元素
 9 E% c, X/ Q) X7 C6 f# p, `string[] split = words.Split(new Char[] { ',', '.' }, 6, StringSplitOptions.None);//返回:{"1","2","3","","4"} 保留空元素3 ~/ Q5 y* j& \1 ]2 ^
 6 F0 s# t6 J9 J5 |+ U
 6. public string[] Split(string[] separator, int count, StringSplitOptions options)
 4 e6 s, n7 }  {$ P6 F9 t
 # D; R6 v' [6 ~. M1 J, w4 |) A  f1 D代码7 g; ]  U8 y5 w
 string[] split = words.Split(new string[] { ",", "." }, 2, StringSplitOptions.RemoveEmptyEntries);//返回:{"1","2.3,,4"} 不保留空元素* H2 i/ }8 |( ~  O; q
 string[] split = words.Split(new string[] { ",", "." }, 6, StringSplitOptions.None);//返回:{"1","2","3","","4"} 保留空元素
 |