1. Split intercept according to a single separator character
String st= "Gt123_1"; string[] Sarray=st.split ('_');
Output: sarray[0]= "GT123", sarray[1]= "1".
2. Use multiple characters to separate strings
String str = "gtazb_jiangjben_123"; string[] Sarray = str. Split (new char[2] {' J ', ' _ '}); foreach (string E in Sarray) { Console.WriteLine (e);}
Output: sarray[0]= "Gtazb", sarray[1]= "Jiang", sarray[2]= "Ben", sarray[3]= "123".
3. To intercept a string based on a string or string group
String str = "gtazb_jiangjben_123"; string[] Sarray = str. Split (New string[]{"Ji", "JB"}, Stringsplitoptions.removeemptyentries); foreach (string E in Sarray) { Console.WriteLine (e);}
Output: sarray[0]= "Gtazb_", sarray[1]= "Ang", sarray[2]= "en_123".
4. Extract the string with the first character of the string starting with the length J;
String str = "gtazb_jiangjben_123"; int start=3,length=8; Console.WriteLine (str. Substring (start-1, length));
Output: Azb_jian.
5. Extracting the string with the right-length I in the string
String str = "gtazb_jiangjben_123"; string tst;int i=5;tst = str. Substring (str. LENGTH-I); Console.WriteLine (tSt);
Output: n_123.
6. Replacing a specific string in a string
String str = "gtazb_jiangjben_123"; string tst;tst = str. Replace ("123", "321"); Console.WriteLine (tSt);
Output: gtazb_jiangjben_321.
7. Delete a specific string in the string jiangj
String str = "gtazb_jiangjben_123"; string tst;tst = str. Replace ("Jiangj", "" "); Console.WriteLine (tSt);
Output: gtazb_ben_123.
8. Delete the string of the specified length (length) for the specified position (i)
String str = "gtazb_jiangjben_123"; int i=5,length=8;str=str.remove (i,length); Console.WriteLine (str);
Output: gtazben_123.
C#8 the operation of a commonly used string