Creates an array of strings by splitting this string with a specified separator.
[Visual Basic] Overloads Public Function Split( _ ByVal separator() As Char _ ) As String () [C#] public string[] Split( char[] separator ); [C++] public: String* Split( __wchar_t* separator[] ) []; [JScript] public function Split( separator : Char[] ) : String[];
Value | Condition |
---|---|
An array containing the substrings of this string | If they are separated by the separating string. |
A one element array that holds Empty | If this instance is an empty string. |
Exception Type | Condition |
---|---|
ArgumentException | If the separating string is null. |
The separator is searched for and, if found, the substring preceding the occurrence is stored as the first element in the array of strings. It is continued in this manner by searching the substring that follows the occurrence.
On the other hand, if the separator is not found, the array of strings will contain this instance as its only element. If the separator is an empty array, whitespace (i.e., IsWhiteSpace) is used as the separator.
"42, 12, 19".Split ({',', ' '}) => {"42", "", "12", "", "19"} "42..12..19".Split({'.'}) => {"42", "", "12", "", "19"} "Banana".Split({'.'}) => {"Banana"} "Darb Smarba".Split({}) => {"Darb", "Smarba"} "Darb Smarba".Split(null) => {"Darb", "Smarba"}
String Class | String Members | System Namespace | String.Split Overload List | Char | CharacterInfo