比如,有一个文本框,内容为"用户名1,用户名2,用户名3,用户名4",我只要取得"用户名1""用户名2""用户名3""用户名4",请问,该怎么写??

解决方案 »

  1.   

    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);
                  }
        }
        }
    }
      

  2.   

    string[] strOld = TextBox.Text.Split(',');