I just found that not only does this code compile, it seems to split the string on any whitespace.
List<string> TableNames = Tables.Split().ToList();
However it didn't show in the intellisense and it's not on the MSDN page.
Is this just an undocumented override? And is it dangerous to use because of that?
It's not an override. In this case, the compiler translates Split()
into Split(char[])
with an empty parameter.
Split is defined as
public string[] Split(
params char[] separator
)
params
lets you specify a variable number of arguments, including no arguments at all. When no arguments are provided (as is in your example), the separator
array will be empty.
From the MSDN page linked above:
If the separator parameter is null or contains no characters, white-space characters are assumed to be the delimiters.
This is why you're seeing the string split on whitespace. This is just default behaviour rather than an undocumented feature, so you're free to use it without fear of unusual side-effects. Well, unless default behaviour changes in a future version of .NET, but that seems fairly unlikely to me since whitespace is a reasonable default.
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