Basic Application of strings and characters

Source: Internet
Author: User

String application # Region Search character // string STR = "123456"; // foreach (char time in Str) // {// console. writeline ("{0}", time); //} // console. readkey (); # endregion # region determines the letter // console. writeline ("input character"); // char c = (char) console. read (); // If (char. isletter (c) // {// If (char. islower (c) // console. writeline ("lowercase letter? "); // Else // console. writeline ("lowercase letter"); // else // console. writeline ("non-letter"); // console. readkey (); # endregion string location string orgstr1 = "123456789"; string orgstr2 = "3456"; int orgstr3 = orgstr1.indexof (orgstr2, 0); console. writeline ("Location:" + orgstr3.tostring (); console. readkey (); Result: 2 returns the string orgstr = "123456789"; string name = orgstr. substring (2, 4); console. write (name); console. readkey (); Result: 3456 string orgstr = "123456789"; string name = orgstr. substring (3); console. write (name); console. readkey (); Result: 456789

String insertion string orgstr1 = "123456"; string orgstr2 = "789"; string orgstr3 = orgstr1.insert (6, orgstr2); console. writeline (orgstr3); console. readkey (); Result: 123456789

String deletion string orgstr1 = "123456789"; string orgstr2 = orgstr1.remove (); console. writeline (orgstr2); console. readkey (); Result: 1239 if no index is set, the replacement string orgstr1 = "123456"; string orgstr2 = orgstr1.replace ("3", "9") is used by default "); console. writeline (orgstr2); console. readkey (); Result: 129456

Character segment string orastr1 = "A | BB | CCC"; char [] arrag = new char [] {'|'}; string [] orastr2 = orastr1.split (arrag, 3); For (INT I = 0; I <orastr2.length; I ++) {console. writeline (orastr2 [I]);} console. readkey (); Result: a bb ccc

Output character string STR = "123456"; foreach (char time in Str) {console. writeline ("{0}", time) ;}console. readkey ();

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.