I don't understand what I am reading wrong...
According to this section of the documentation, Strings should be able to be split using a second String as the seperator. The documentation says:
However, when I actually attempt this, the code fails and throws an error, claiming that the seperator must be a char or string array, but not a String itself.
In fact, this seems to be backed up by the code internals itself. If I look at System.String, I can find overloads for a variety of seperator arguments, but none of them are for a seperator simply of type String:
The documentation says that the overload accepting a String as a seperator has been present since .NET Core 2.0? So this shouldn't be a brand-new feature to .NET, I don't believe?
So what am I reading incorrectly in this documentation? What does the linked section mean if not that a String can be used as the seperator to .Split() other strings? I'm completely baffled.
According to this section of the documentation, Strings should be able to be split using a second String as the seperator. The documentation says:
Split(String, StringSplitOptions)
Splits a string into substrings that are based on the provided string separator.
C#:public string[] Split (string? separator, StringSplitOptions options = System.StringSplitOptions.None);
Parameters
separator
String
A string that delimits the substrings in this string.
options
StringSplitOptions
A bitwise combination of the enumeration values that specifies whether to trim substrings and include empty substrings.
Returns
String[]
An array whose elements contain the substrings from this instance that are delimited by separator.
However, when I actually attempt this, the code fails and throws an error, claiming that the seperator must be a char or string array, but not a String itself.
Argument 1: Cannot conver from 'string' to 'char'.
In fact, this seems to be backed up by the code internals itself. If I look at System.String, I can find overloads for a variety of seperator arguments, but none of them are for a seperator simply of type String:
System.String definition:
public String[] Split(char[] separator, int count, StringSplitOptions options);
public String[] Split(String[] separator, StringSplitOptions options);
public String[] Split(String[] separator, int count, StringSplitOptions options);
public String[] Split(char[] separator, int count);
public String[] Split(params char[] separator);
public String[] Split(char[] separator, StringSplitOptions options);
The documentation says that the overload accepting a String as a seperator has been present since .NET Core 2.0? So this shouldn't be a brand-new feature to .NET, I don't believe?
So what am I reading incorrectly in this documentation? What does the linked section mean if not that a String can be used as the seperator to .Split() other strings? I'm completely baffled.