According to both Intellisense and MSDN doc on string.Split, there are no parameterless overloads of string.Split. Yet if I type in
string[] foo = bar.Split();
It compiles. And it works. I have verified this in both Visual Studio 2008 and 2010. In both cases intellisense does not show the parameterless overload.
Is there a reason for this? Are there any other missing overloads from the MSDN/Intellisense docs? Usually browsing through overloads in intellisense is how I best determine which overload to use. I'd hate to think I am missing other available options throughout the .Net framework.
EDIT: as shown above, it splits on whitespace.
That is because Split has a params overload. Giving no parameters is the same as giving an empty array. In other words, you are calling this overload.
"some text".Split();
Is the same as:
"some text".Split(new char[0]);
Here is the documentation on the params keyword. As you probably know, it is used for giving a method a variable number of parameters. That number may be zero.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With