About method Sharing of string types in C #

Source: Internet
Author: User
Equals (String value)
Returns a bool type, compares equality, and is similar to "= ="

Compareto (String value)
Judging size, large return 1 small return-1 equal return 0

IndexOf (String value)
Find this character in the current string, starting with the first one, finding the index where it was found the first time, and if it cannot find the return-1
Example: 1123 If you look for 1, return 0.

LastIndexOf (String value)
The same as above, but from the back forward, return the first index found
Example: 1123 If you look for 1, return 1.

Join (String value,string[] string,int statindex,int count) //After two parameters one is the starting index, one is the number of functions
This method is not the same as other methods, the call is made from string, the function is to concatenate the array through a string to return a string
String[] ary={"A", "B", "C"};
String Result=string.join ("_", ary);
The value of the last result is A_b_c connected by "_".

Split (char value)
Separates a string type with char. Example:

String[] ary;string str2;string str1= "A_b_c_d"; ary=str1. Split ('_');   Note that the parameter of the method is a char type, which returns an array of foreach (string s in ary) {    str2+=s;}

The last str2 value is ABCD

SubString (int index,int length)
Intercepts a specified length of string from a specified position

String str1= "ABCDEFG"; str1. SubString, str1 the result is bcstr1. SubString (2,3);

The CDE 2 represents the index position, and 3 indicates the length

ToLower ();
Convert all to lowercase

Touper ();
Convert all to Uppercase

Trim ();
Remove front and back spaces

Related Article

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.