求-----split的用法。

解决方案 »

  1.   

    string s ="a|b|c|d";
    string[] des = s.Split(new char []{'|'});
      

  2.   


    string[] des = "a,b,c,d".Split( ",".ToCharArray() );
      
    --------------------------------------------------------------
    程序,犹如人生。
      

  3.   

    dim a()as string
    a=split("a,s,d,f,g,h".",")
    则a(0)为a
    a(1)为s
    a(5)为h
      

  4.   

    使用这个重载有时会出问题,最好使用
    string s ="a|b|c|d";
    string[] des = s.Split(new string[]{"|"});
      

  5.   

    比如有string ss = "sdfsfd.dsfdf.sdfsaf";
    那么string[] ssArray = ss.Split('.');
      

  6.   

    using System;public class StringSplit2 {
        public static void Main() {        string delimStr = " ,.:";
        char [] delimiter = delimStr.ToCharArray();
            string words = "one two,three:four.";
            string [] split = null;    Console.WriteLine("The delimiters are -{0}-", delimStr);
        for (int x = 1; x <= 5; x++) {
            split = words.Split(delimiter, x);
                Console.WriteLine("\ncount = {0,2} ..............", x);
            foreach (string s in split) {
                    Console.WriteLine("-{0}-", s);
                  }
        }
        }
    }