split涵数的应用

来源:互联网 发布:jdk1.8 linux 64 下载 编辑:程序博客网 时间:2024/04/30 21:47

    string words = "this.is a list of words, with: a bit of punctuation.";

   string[] split = words.Split(new Char[]{' ', ',', '.', ':'});

   foreach (string s in split)
   {

    if (s.Trim() != "")
     //Console.WriteLine(s);
     Response.Write(s);
   }

 

其中new Char[]{' ', ',', '.', ':'})中,可以为一个也可以为多个,如new Char[]{' .'}

原创粉丝点击