[C #] Go [String String Intercept

Source: Internet
Author: User
C # Several commonly used string interception

One

1. Take the first I character of a string

(1) String str1=str. Substring (0,i);

(2) String str1=str. Remove (i,str. LENGTH-I);

2. Remove the first I character of a string

String Str1=str. Remove (0,i);

String Str1=str. SubString (i);

3, start from the right to take I characters:

String Str1=str. SubString (str. LENGTH-I);

String Str1=str. Remove (0,str. LENGTH-I);

4. Remove I characters from the right:

String Str1=str. Substring (0,str. LENGTH-I);

String Str1=str. Remove (str. Length-i,i);

5.

6. If there is "ABC" in the string, replace it with "ABC"
Str=str. Replace ("abc", "abc");

7. C # intercepts the last character of a string

Str1. Substring (str1. LastIndexOf (",") +1);

8. C # intercepts the last character of a string

K = K.substring (k.length-1, 1);

[C #] Go [String String Intercept

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.