System Namespace String Class
Identifies the substrings in the given String that are delimited by one or more characters specified in an array, then places the substrings into a String array. A parameter specifies the maximum number of array elements to return.
[ VB ]
<Serializable>
Overloads Public Function Split ( _
ByVal separator ( ) As Char, _
ByVal count As Integer _
) As String ( )
[ C# ]
[ Serializable ]
public string [ ] Split (
char [ ] separator,
int count
);
[ C++ ]
[ Serializable ]
public: String* Split (
__wchar_t separator __gc [ ],
int count
) __gc [ ];
[ JScript ]
public Serializable
function Split (
separator : Char [ ],
count : int
) : String [ ];
- separator
- An array of Unicode characters that delimit the substrings in the given String, an empty array containing no delimiters, or a null reference ( Nothing in Visual Basic ).
- count
- The maximum number of array elements to return.
An array consisting of a single element containing this instance, if this instance contains none of the characters in separator.
-or-
An array of substrings if this instance is delimited by one or more of the characters in separator.
-or-
An array of the substrings in the given String delimited by white space characters if those characters occur and separator is a null reference ( Nothing in Visual Basic ) or contains no delimiter characters.
Empty is returned for any substring where two delimiters are adjacent, or a delimiter is found at the beginning or end of this instance.
Delimiter characters are not included in the substrings.
If there are more than count substrings in the given String, the first count minus 1 substrings are returned in the first count minus 1 elements of the return value, and the remaining characters in the given String are returned in the last element of the return value.
For example:
Input |
separator, count |
Output |
"42, 12, 19" |
new Char [ ] {',', ' '}, 2 |
{"42", " 12, 19"} |
"42..12..19" |
new Char [ ] {'.'},4 |
{"42", "", "12", ".19"} |
"Banana" |
new Char [ ] {'.'},2 |
{"Banana"} |
"Darb\nSmarba" |
new Char [ ] {}, 1 |
{"Darb\nSmarba"} |
"Darb\nSmarba" |
new Char [ ] null,2 |
{"Darb", "Smarba"} |
"Darb\nSmarba" |
new Char [ ] null,100 |
{"Darb", "Smarba"} |
String Members String.Split Overload List Char Array Int32 Concat Insert Join Remove Replace Substring Trim