c#字符串练习

  1,分出字符串

  

 protected void Button1_Click(object sender, EventArgs e)
        {
            //把一个字符串按|号分出来输出,但不输出掉空格
            string a = "a|b||||c||d";

            StringBuilder sb=new StringBuilder ();

            

            string[] ss = a.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);

          for (int i = 0; i < ss.Length; i++)
            {
               sb.Append(ss[i]);
            }

            Response.Write(sb);
        }

 

posted @ 2013-03-21 23:03  apecoder  阅读(144)  评论(0编辑  收藏  举报