Share via


Split Method (Char[])

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Returns a string array that contains the substrings in this instance that are delimited by elements of a specified Unicode character array.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Function Split ( _
    ParamArray separator As Char() _
) As String()
public string[] Split(
    params char[] separator
)
public:
array<String^>^ Split(
    ... array<wchar_t>^ separator
)
member Split : 
        separator:char[] -> string[] 
public function Split(
    ... separator : char[]
) : String[]

Parameters

  • separator
    Type: array<System. . :: . .Char> [] () [] []
    An array of Unicode characters that delimit the substrings in this instance, an empty array that contains no delimiters, or nullNothingnullptrunita null reference (Nothing in Visual Basic).

Return Value

Type: array<System. . :: . .String> [] () [] []
An array whose elements contain the substrings in this instance that are delimited by one or more characters in separator. For more information, see the Remarks section.

Remarks

Delimiter characters are not included in the elements of the returned array.

If this instance does not contain any of the characters in separator, the returned array consists of a single element that contains this instance.

If the separator parameter is null Nothing nullptr unit a null reference (Nothing in Visual Basic) or contains no characters, white-space characters are assumed to be the delimiters. White-space characters are defined by the Unicode standard and return true if they are passed to the Char.IsWhiteSpace method.

Each element of separator defines a separate delimiter character. If two delimiters are adjacent, or a delimiter is found at the beginning or end of this instance, the corresponding array element contains Empty. The following table provides examples.

String value

Separator

Returned array

"42, 12, 19"

new Char[] {',', ' '} (C#)

Char() = {","c, " "c}) (Visual Basic)

{"42", "", "12", "", "19"}

"42..12..19"

new Char[] {'.'} (C#)

Char() = {"."c} (Visual Basic)

{"42", "", "12", "", "19"}

"Banana"

new Char[] {'.'} (C#)

Char() = {"."c} (Visual Basic)

{"Banana"}

"Darb\nSmarba" (C#)

"Darb" & vbLf & "Smarba" (Visual Basic)

new Char[] {} (C#)

Char() = {} (Visual Basic)

{"Darb", "Smarba"}

"Darb\nSmarba" (C#)

"Darb" & vbLf & "Smarba" (Visual Basic)

null (C#)

Nothing (Visual Basic)

{"Darb", "Smarba"}

.NET Framework Security

See Also

Reference

String Class

Split Overload

System Namespace