I’m trying to split a song title into two strings- the artist and song.
I receive the original string like this: “artist – song”.
Using this code, I split the string using ‘-‘ as the spliiter:
char[] splitter = { '-' };
string[] songInfo = new string[2];
songInfo = winAmp.Split(splitter);
This works fine and all, except when I get to a band with ‘-‘ in the name, like SR-71.
However, since the original strings are separated with a space then a – and a space again (like SR-71 – Tomorrow), how would I split the string so this happens? I tried changing splitter to a string and inputting
string[] splitter = { " - " };
in it, but it returns that there is no overload match.
For some reason,
string.Splithas no overload that only takes a string array.You need to call this overload:
Don’t ask me why.