Detailed explanation of string. split usage in C
- 2021-12-19 06:30:49
- OfStack
Method 1
string s=abcdeabcdeabcde;
string[] sArray=s.Split('c') ;
foreach(string i in sArray)
Console.WriteLine(i.ToString());
Output the following results:
ab
deab
deab
de
Method 2
We see that the result is a split with 1 specified character. Use another construction method for multiple words
Character to split:
string s="abcdeabcdeabcde";
string[] sArray1=s.Split(new char[3]{'c','d','e'}) ;
foreach(string i in sArray1)
Console.WriteLine(i.ToString());
You can output the following results
ab
ab
ab
The above is the site to introduce you C # string. split usage details, I hope to help you, if you have any questions welcome to leave me a message, this site will reply to you in time!