在C#winform中
有一个textBox1的内容如下,MultiLine设了True,每一行就平常用的回车隔开:
123
111
222
555
333
--------------------------------------
str str1="555";
查找str1="555"是否在textBox1的某一行中是否存在怎么写呀?
不会遍历textBox,只会遍历listBox
----------------------------------------------
int i=0;
遍历textBox1每一行的内容
{
 if (str1==textBox1其中一行的值)
 {i:=i+1;}
}
------------------------------------------------
遍历获取textBox1每一行的内容的值怎么写呀?

解决方案 »

  1.   

     string[] tlines = textBox1.Lines;            foreach (string link in tlines)
                {
                    MessageBox.Show(link);
                }
      

  2.   


     if(textbox1.text.touper().IndexOf(str1.touper())>0)
       i++;
      

  3.   

    判断
    if (Array.IndexOf(textBox1.Lines, "333") >= 0)
    //存在;
      

  4.   

    //查找
     textBox1.Lines.Contains("555)
    or
      Array.IndexOf(textBox1.Lines,"")>-1//遍历
                foreach (string content in  textBox1.Lines)
                {
                    
                }
      

  5.   

    For each i as string in Textbox1.text.lines
        if i="555" then
            msgbox("I Find It!")
        end if
    next
      

  6.   

    楼上搞错了,应该为
    For each i as string in Textbox1.lines
        if i="555" then
            msgbox("I Find It!")
        end if
    next
      

  7.   

    var num = textBox1.Text.Split(new char[] { '\r', '\n' }, StringSplitOptions. RemoveEmptyEntries).Select((i, x) => new { i, x }).Where(x => x.x == "555").First().i;
      

  8.   


                foreach(string str in richTextBox1.Lines)
                {
                    if (str == "555")
                    {
                        MessageBox.Show(str);
                    }
                }richTextBox1.Lines 是一个string类型的数组 直接用foreach遍历就可以了