+ -
当前位置:首页 → 问答吧 → 如何遍历?

如何遍历?

时间:2011-12-21

来源:互联网

在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每一行的内容的值怎么写呀?

作者: SKY1006   发布时间: 2011-12-21

C# code
 string[] tlines = textBox1.Lines;

            foreach (string link in tlines)
            {
                MessageBox.Show(link);
            }

作者: DENQH   发布时间: 2011-12-21


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

作者: qq598235031   发布时间: 2011-12-21

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

作者: dalmeeme   发布时间: 2011-12-21

//查找
 textBox1.Lines.Contains("555)
or
  Array.IndexOf(textBox1.Lines,"")>-1

//遍历
  foreach (string content in textBox1.Lines)
  {
   
  }

作者: Sandy945   发布时间: 2011-12-21

相关阅读 更多

热门下载

更多