String..::.Split Method
This page is specific to:.NET Framework Version:
.NET Framework Class Library
String..::.Split Method

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

Overload List

  NameDescription
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkSplit(array<Char>[]()[])Returns a string array that contains the substrings in this instance that are delimited by elements of a specified Unicode character array.
Public methodSplit(array<Char>[]()[], Int32)Returns a string array that contains the substrings in this instance that are delimited by elements of a specified Unicode character array. A parameter specifies the maximum number of substrings to return.
Public methodSplit(array<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.
Public methodSplit(array<String>[]()[], StringSplitOptions)Returns a string array that contains the substrings in this string that are delimited by elements of a specified string array. A parameter specifies whether to return empty array elements.
Public methodSplit(array<Char>[]()[], Int32, StringSplitOptions)Returns a string array that contains the substrings in this string that are delimited by elements of a specified Unicode character array. Parameters specify the maximum number of substrings to return and whether to return empty array elements.
Public methodSplit(array<String>[]()[], Int32, StringSplitOptions)Returns a string array that contains the substrings in this string that are delimited by elements of a specified string array. Parameters specify the maximum number of substrings to return and whether to return empty array elements.
Top
See Also

Reference

Community Content

One more overloaded version : string.Split()
Added by:R Petrusha - MSFT

One more overloaded version : string.Split() works :)

I think string.Split() works as string.Split(Char[]) because Char[] can be null.

-----
While it is true that the String.Split method can be called with no parameters, it is not true that it is an additional overload of the String.Split method. Instead, compiler overload resolution in the Visual Basic and C# compilers is responsible for translating the call to the String.Split method into a call to the String.Split(system.Char[]) method.

This happens because the character array parameter of the String.Split(System.Char[]) method is marked with the ParamArray attribute. The ParamArray attributre allows a method to be called with zero, one, or more optional arguments, all of which in this case must be of type Char. When thye compiler attempts to resolve the call to the parameterless String.Split() method, it finds no direct match. It then searches for the closest match, which is the String.Split(Char[]) method that accepts a variable number of Char values in an array. In the call to the parameterless Split method, there are no arguments that are Char values, but this absence of Char arguments is equivalent to an empty array of type Char. Because of this, overload resolution succeeds, and the compiler creates an empty Char array on the fly and passes it to the String.Split(Char[]) method.

You can verify that the String.Split(Char[]) method rather than a parameterless String.Split() method is called by using ILDasm to examine the IL for a method that calls String.Split(). The IL shows that the method creates an empty Char array, then passes it to the String.Split(Char[]) method.
© 2010 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View