String.Split Method (Char, StringSplitOptions)
Returns a string array that contains the substrings in this string that are delimited by elements of a specified Unicode character array. A parameter specifies whether to return empty array elements.
Assembly: mscorlib (in mscorlib.dll)
[<ComVisibleAttribute(false)>] member Split : separator:char * options:StringSplitOptions -> string
- Type: System.Char
An array of Unicode characters that delimit the substrings in this string, an empty array that contains no delimiters, or a null reference (Nothing in Visual Basic).
Return ValueType: System.String
An array whose elements contain the substrings in this string that are delimited by one or more characters in separator. For more information, see the Remarks section.
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 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. However, if the separator parameter in the call to this method overload is a null reference (Nothing in Visual Basic), compiler overload resolution fails. To unambiguously identify the called method, your code must indicate the type of the null. The following example shows several ways to unambiguously identify this overload.
Each element of separator defines a separate delimiter character. If the options parameter is RemoveEmptyEntries and the length of this instance is zero, an empty array is returned.
The Split methods allocate memory for the returned array object and a String object for each array element. If your application requires optimal performance or if managing memory allocation is critical in your application, consider using the IndexOf or IndexOfAny method, and optionally the Compare method, to locate a substring within a string.
If you are splitting a string at a separator character, use the IndexOf or IndexOfAny method to locate a separator character in the string. If you are splitting a string at a separator string, use the IndexOf or IndexOfAny method to locate the first character of the separator string. Then use the Compare method to determine whether the characters after that first character are equal to the remaining characters of the separator string.
In addition, if the same set of characters is used to split strings in multiple Split method calls, consider creating a single array and referencing it in each method call. This significantly reduces the additional overhead of each method call.
In the .NET Framework 3.5 and earlier versions, if the Split method is passed a separator that is a null reference (Nothing in Visual Basic) or contains no characters, the method uses a slightly different set of characters to split the string than the Trim method does to trim the string. In the .NET Framework 4, both methods use an identical set of Unicode white-space characters.
.NET FrameworkSupported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0
.NET Framework Client ProfileSupported in: 4, 3.5 SP1
Portable Class LibrarySupported in: Portable Class Library
.NET for Windows Store appsSupported in: Windows 8
.NET for Windows Phone appsSupported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1
Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.