So I looked at the String.Split()
method in C# today and I realized that you can pass it zero arguments as well which I never considered.
What is the default delimiter when you use Split()
without any parameters?
The split() method splits a string into a list. You can specify the separator, default separator is any whitespace. Note: When maxsplit is specified, the list will contain the specified number of elements plus one.
Splitting the String Based on Multiple Delimiters:Multiple delimiters can be specified as a parameter to the split() function by separating each delimiter with a |. The given string or line with multiple delimiters is separated using a split function called re. split() function.
Description. Python string method split() returns a list of all the words in the string, using str as the separator (splits on all whitespace if left unspecified), optionally limiting the number of splits to num.
In case of no values it's white space - source from here:
If the separator argument is null or contains no characters, the method treats white-space characters as the delimiters. White-space characters are defined by the Unicode standard; they return true if they are passed to the Char.IsWhiteSpace method.
If you look at the source, you can see that if you're passing null
or an empty array (default for a params
parameter if you omit the argument), it's using Char.IsWhiteSpace
to check if the string contains whitespace characters and adds them to the list of separators.
ProTip! Next time you're wondering what a framework method does, check out the source at sourceof.net.
The default is whitespace - but to add upon the other answers, this includes \n
newline characters.
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