Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
System Namespace
String Class
String Methods
Split Method
Collapse All/Expand All Collapse All
Members FilterMembers Filter
Frameworks FilterFrameworks Filter
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.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.

  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
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
One more overloaded version : string.Split()      Yaşarkurt ... R Petrusha - MSFT   |   Edit   |   Show History

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.
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker