Manipulation of strings

Source: Internet
Author: User

strings: string non-variability of strings when you re-assign a string, the old value is not destroyed, but a space is re-opened   when the program is finished, the GC scans the entire memory, if you find that some space is not pointed, immediately destroy them we can consider a string type as a read-only group of type char ToCharArray () new String () ToString () ToUpper (): Converts a string to uppercase ToLower (): Convert string to lowercase S1. Equals (S2,stringcomparison.ordinalignorecase): Compares two strings ignoring case S1. Split (new char[]{the character to be split},stringsplitoptions.removeemptyentris) splits the string and removes the empty string refer to Using.system.Text.RegularExpressions first regex.split (str, "JS", regexoptions.ignorecase); Split String string a= "123456789";//Convert to 12-345-6789 A=int. Parse (a). ToString ("##-###-####");   string. Replace ("character to replace", "substituted character") string. SubString (position to start intercept): Intercept string string. SubString (the position to begin interception, the length of interception) contains ("string") to determine whether it contains string.startwith ("string") to determine whether to start with what string.endswith ("string") indexof (' character ') calculates the position of the character at the first occurrence of the string LastIndexOf Find the last occurrence of a character in a string   . Trim () Remove empty items before or after a string  . Rtirm ("1") a string in parentheses   . TrimStart ()   . TrimEnd () followed by an array of type char to move the elements in the divisor group string. IsNullOrEmpty () to determine if it is null or empty string. Join ("delimiter", string[]) joins the array according to the specified string, returning a string   turns a character array into a string. String S=new string (char array); String s=new string (' C ', 5); Gets a string of 5 characters   declares a string, but does not need to assign a value to it string s =null; string s= ""; string s= String. Empty;   simple string manipulation at present the little brother summed up so much, welcome to the Fairy Supplement.

Manipulation of strings

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.