Summary of String methods in C #

Source: Internet
Author: User
Tags string methods

The following describes the methods of the string class in C:

1. string (char []) uses the specified string array to construct a new string object.

 

2. int Compare (string a, string B, bool case) when comparing strings a, B, and case are true, the case is case insensitive. When a> B returns a positive number, when a <B returns a negative number, a = B returns 0

 

3. bool EndsWith (string) determines whether the current string ends with the specified string

 

4. bool StartsWith (string) determines whether the current string starts with the specified string

 

5. int IndexOf () returns the position of the specified character or string in the current string

 

6. int LastIndexOf () returns the last matching position of the specified character or string

 

7. string Insert (int, string) inserts a specified string into the current string

 

8. string Replace (string, string) string replacement

 

9. string Remove (int, int) deletes a specified number of characters from the specified position

 

10. ToUpper () ToLower () string case-insensitive Conversion

 

11. string SubString (int, int) returns the specified number of strings starting from the specified position

 

The following example describes some methods:

String str1 = "Hello ";

String srr2 = "World ";

String Upper, str3;

Upper = str1.Upper (); // converts str1 to uppercase

Str3 = str1.Insert (str1.Length, str2); // The content of str3 is HelloWorld


Author: happy_rita

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.