Reputation: 2423
I have written many lines to a text file and I have divided each line into parts by putting three spaces between parts. Here is an example of a line :
1 khashayar home
Now I want to read and split each line by using
arraytobeprinted = ss.Split(' ');
but I get this error:
There are too many characters in character literals
How can I fix this ?
Upvotes: 0
Views: 136
Reputation: 223402
You can try String.Split Method (String[], StringSplitOptions) for the same result.
string[] array2 = ss.Split(new string[]{" "}, StringSplitOptions.None);
Upvotes: 0
Reputation: 9950
Use ss.Split(null) or ss.Split(new char[0]), this will solve your problem easiest way.
Happy Coding!!!
Upvotes: 0
Reputation: 10941
You're passing a character as a splitting delimiter. Try passing a string like this:
var parts = ss.Split(new[] { " " }, StringSplitOptions.None);
Upvotes: 3