In asp.net c #, String. Split has six overload methods. The following is an example. If you need it, you can refer to it.
Below we use some examples to illustrate how to use (the following string words = "1, 2.3, 4 ";):
Split (Char ())? Invalid statement execution ?? Column ,???? The column contains ???? Why ??? By the specified Unicode character? The child string separated by the column elements.
The Code is as follows: |
Copy code |
1. public string [] Split (params char [] separator) String [] split = words. Split (new Char [] {','}); // return value: {"1", "2.3", "", "4 "} String [] split = words. split (new Char [] {',', '. '}); // return: {"1", "2", "3", "", "4 "}
|
Split (Char (), Int32 )? Invalid statement execution ?? Column ,???? The column contains ???? Why ??? By the specified Unicode character? The child string separated by the column elements. ?? Do you have to pay for it? Why? Are you confused? /P>
The Code is as follows: |
Copy code |
2. public string [] Split (char [] separator, int count) String [] split = words. split (new Char [] {',', '. '}, 2); // return: {"1", "2.3, 4 "} String [] split = words. split (new Char [] {',', '. '}, 6); // return: {"1", "2", "3", "", "4 "}
|
Split (Char (), StringSplitOptions )? Invalid statement execution ?? Column ,???? Column inclusion ??? Which of the specified Unicode characters? The child string separated by the column elements. ?? Payment overdue? Why? Column element.
The Code is as follows: |
Copy code |
3. public string [] Split (char [] separator, StringSplitOptions options) String [] split = words. split (new Char [] {',', '. '}, StringSplitOptions. removeEmptyEntries); // return value: {"1", "2", "3", "4"} empty element not retained String [] split = words. split (new Char [] {',', '. '}, StringSplitOptions. none); // return: {"1", "2", "3", "", "4"} retain null Elements
|
Split (String (), StringSplitOptions )? Invalid statement execution ?? Column ,???? Column inclusion ??? Which of the following is the specified string? The child string separated by the column elements. ?? Payment overdue? Why? Column element.
The Code is as follows: |
Copy code |
4. public string [] Split (string [] separator, StringSplitOptions options) String [] split = words. split (new string [] {",", ". "}, StringSplitOptions. removeEmptyEntries); // return value: {"1", "2", "3", "4"} empty element not retained String [] split = words. split (new string [] {",", ". "}, StringSplitOptions. none); // return: {"1", "2", "3", "", "4"} retain null Elements
|
Split (Char (), Int32, StringSplitOptions )? Invalid statement execution ?? Column ,???? Column inclusion ??? Which of the specified Unicode characters? The child string separated by the column elements. ?? Pay-as-you-go? Why? Why? ? About to owe? How old is it? Column element.
The Code is as follows: |
Copy code |
5. public string [] Split (char [] separator, int count, StringSplitOptions options) String [] split = words. split (new Char [] {',', '. '}, 2, StringSplitOptions. removeEmptyEntries); // return value: {"1", "2.3, 4"} empty elements are not retained. String [] split = words. split (new Char [] {',', '. '}, 6, StringSplitOptions. none); // return: {"1", "2", "3", "", "4"} retain null Elements
|
Split (String (), Int32, StringSplitOptions )? Invalid statement execution ?? Column ,???? Column inclusion ??? Which of the following is the specified string? The child string separated by the column elements. ?? Pay-as-you-go? Why? Why? ? About to owe? How old is it? Column element.
The Code is as follows: |
Copy code |
6. public string [] Split (string [] separator, int count, StringSplitOptions options) String [] split = words. split (new string [] {",", ". "}, 2, StringSplitOptions. removeEmptyEntries); // return value: {"1", "2.3, 4"} empty elements are not retained. String [] split = words. split (new string [] {",", ". "}, 6, StringSplitOptions. none); // return: {"1", "2", "3", "", "4"} retain null Elements |
Note that the public string [] Split (string [] separator) function is not overloaded)
Okay.