请教各位,我想逐行读取文本框中的内容,当遇到文本框中以T字母打头时行时,读取这一行的内容,要怎么实现啊,多谢帮忙啦!
文本框中内容大致为:
D12345667
T2355678900--
A235678990SSDFGHU7
T234567890000--II
...
...

解决方案 »

  1.   

    解析吧
    str.split('\n'),然后遍历数组吧
      

  2.   

    你可以使用richTextBox控件. foreach (string s in richTextBox1.Lines)
                { 
                ...
                }
      

  3.   

            void test()
            {
                string s = @"D12345667
    T2355678900--
    A235678990SSDFGHU7
    T234567890000--II";
                string[] ss=s.Split('\n');
                foreach (string s2 in ss)
                {
                    if (s2.Trim().StartsWith("T"))
                    {
                        ftWinCommon.MsgBox(s2);
                    }
                }
            }
      

  4.   


    string[] str = textBox1.Text.Split['\n'];
                for (int i = 0; i < str.Length; i++)
                {
                    if (str[i].Substring(0, 1) == "T")
                    {
                        MessageBox.Show(str[i]);//取出T开头的行
                    }
                }
      

  5.   


    just like this ...
      

  6.   

    我也有个问题搞不懂,StringBuilder怎么不设个 .Lines[i] 集合,每次都要split之。
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("D12345667");
                sb.AppendLine("T2355678900");
                sb.AppendLine("A235678990SSDFGHU7");
                sb.AppendLine("T234567890000--II");
                foreach (string s3 in sb) //此处不行
                {            }
      

  7.   

    string[] st=str.Split(new string[]{"\r\n"},StringSplitOptions.RemoveEmptyEntries)
    foreach(string data in st)
    {
        ……ok啦
    }
      

  8.   

     try
                {
                    // Create an instance of StreamReader to read from a file.
                    // The using statement also closes the StreamReader.
                    using (StreamReader sr = new StreamReader(@"D:\新建文本文档.txt"))
                    {
                        String line;
                        // Read and display lines from the file until the end of 
                        // the file is reached.
                        while ((line = sr.ReadLine()) != null && (line = sr.ReadLine()).StartsWith("T"))
                        {
                            Console.WriteLine(line);
                        }
                    }
                }
                catch (Exception e)
                {
                    // Let the user know what went wrong.
                    Console.WriteLine("The file could not be read:");
                    Console.WriteLine(e.Message);
                }
      

  9.   

          void test()
            {
                string s = @"D12345667
    T2355678900--
    A235678990SSDFGHU7
    T234567890000--II";
                string[] ss=s.Split('\n');
                foreach (string s2 in ss)
                {
                    if (s2.Trim().StartsWith("T"))
                    {
                        ftWinCommon.MsgBox(s2);
                    }
                }
            }
      

  10.   

    foreach (string s in richTextBox1.Lines)
    {
    }
    不太明白,望指点指点,不甚感激啊