C # traverse text box

Source: Internet
Author: User

#regiontext box Specify position add carriage return characterPrivate voidButton1_Click (Objectsender, EventArgs e) {            #region             //Query the first letter position//string str = "Ab0ab0ab0ab0"; //int one = str. IndexOf ("0"); //returns the position "index" where 0 appears//for (int i=0;i<str. length;i++)//{            //One = str. IndexOf ("0", ++one); //the second occurrence of the position//if (one==-1)//    {            //Break ;//not found//    }            //MessageBox.Show (one.            ToString ()); //}            #endregion            stringstr =TextBox1.Text.Trim (); intone = str. IndexOf ("</option>");//returns the position "index" where 0 appearsstr = str. Insert (one +9,"\ r \ n");  for(inti =0; I < Str. Length; i++) { One= str. IndexOf ("</option>", ++one);//the second occurrence of the position                if(One = =-1)                {                     Break;//not found                }                Else{str= str. Insert (one +9,"\ r \ n"); }} TextBox1.Text=str; }        #endregion        #regionList to string to remove text specified lineList<string> list =Newlist<string>(); Private voidButton2_Click (Objectsender, EventArgs e) {list.            Clear (); //            foreach(stringLineinchtextbox1.lines) {if(!line. Contains ("Select") ) {list.                ADD (line); }} TextBox1.Text=string. Join ("\ r \ n", List.        ToArray ()); }        #endregion

C # traverse text box

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.