'How to split a string array using char as delimiter [duplicate]

I want to add ' char as delimiter to my string array but I have error telling conversion string to char impossible.

I see this How to split a string by a specific character?

string ineedtosplitthis = "i want 'to' split this";
string[] splitTest = ineedtosplitthis.Split("'").ToString();


Solution 1:[1]

The issues is that you have the .ToString() after your statement.
Change it to this:

string ineedtosplitthis = "i want 'to' split this";
string[] splitTest = ineedtosplitthis.Split('\'');

The reason why this code doesn't work:
string[] splitTest = ineedtosplitthis.Split("'").ToString();
Is because you are converting it to a string via ToString();, while assigning it to a string[].

Split(); already returns a string[], so there is no need to convert it.
Hope this explanation helped :)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 gunr2171