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