怎样检测一个字符串里含有多少个换行符,并且截取子字符串到第i条换行符,后面显示……,实现 [ 更多 ] 的效果。(下图)

解决方案 »

  1.   

      using (StreamReader read = new StreamReader("password.txt"))
                {                passall = read.ReadToEnd();  //读取一个文件,显示换行符
                    read.Close();
                }
                yan = passall.Split((Char)10);
                MessageBox.show("总共有换行符"+yan.length);
      

  2.   

    想把类似下面的字符串用split方法以<br>字符为界分割到一个字符串数组,并去掉里面的<br>字符。怎么弄阿。
    "hello<br>fjadalsjglasjgfasjgja<br>fja;skfjka;sgja;sjgas;gjasldgjwi<br><br>"字符串数组元素的值分别为:hello
    goodmorfalsdjflasjglagjasgjakdjgajgfasjfgajsgjalkjg
    fja;skfjka;sgja;sjgas;gjasldgjwi
    fjaskdfj
    fkja
      

  3.   

    上次回答你的问题好像没有结贴吧,赶紧查一下有没有没结的帖子,我写了个例子br.aspx
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="br.aspx.cs" Inherits="br" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
        </div>
        </form>
    </body>
    </html>br.aspx.cs
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;public partial class br : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string str = "hello <br>fjadalsjglasjgfasjgja <br>fja;skfjka;sgja;sjgas;gjasldgjwi <br> <br>";        string[] str_arr={"<br>"};        string[] arr = str.Split(str_arr, StringSplitOptions.RemoveEmptyEntries);        for (int i = 0; i < arr.Length; i++)
            {
                Response.Write("第" + (i + 1) + "个元素为" + arr[i].ToString() + "<p></p>");            //根据你自己的需要调用
            }    }
    }
      

  4.   

                string yan = "asdasdasd<br>";
                StringBuilder ai = new StringBuilder(yan);
                string wo=ai.Replace("<br>", "我").ToString ();
                string[]hehe = wo.Split('我');
                foreach (string mo in hehe)
                {
                    listBox1.Items.Add(mo);
                }