I'm currently trying to do string comparisons - I know it's not best to do so, but I need to for this solution.
If I were parsing a line such as: Raiden: HelloWorld
, I would want to extract the separate strings Raiden
and HelloWorld
for further use.
I currently do achieve this by performing the following:
var list = channelMessage.Split(' ', ':', '\n', '\0');
However, when printing the result and length of each item in list
the HelloWorld
string's length is incorrect.
Output:
Raiden | length: 6
HelloWorld | length: 11
HelloWorld
's length should be 10, not 11. I'm assuming there's null characters somewhere in the line, but cannot figure out how to remove them all.
Sidenote: If I remember correctly, c#'s strings are arrays, and the last character of the array is a '\0' but I tried removing it (as seen above)
Is my assumption correct, and how can I correctly get HelloWorld
's length to 10?
Split(':')
and then justTrim()
all the items in the resulting list... Really no need to split on all those other characters.