tags:

views:

153

answers:

2

I want to compile my C# code. I was parsing a string by "....",

string[] parts = line.Split(new[] { '....' }, 2);

Then I got an error:

Too many characters in character literal

The line looks like this:

abc....  starting word in english

I think that I need to convert .... to =. Then everything would work fine. Is there any other way?

+5  A: 

You can only split by char by passing a single character: '.'.

Split using string instead:

string[] parts = line.Split("....", 2);
GenericTypeTea
+4  A: 

Try using the Split method:

string[] parts = line.Split("....", 2, StringSplitOptions.None);
Darin Dimitrov
yes, and the import point is: if you have more than one character in your "delimiters" string as first parameter to `.Split()`, use the double quotes `"....."` rather than single quotes `'....'`
marc_s
it is not worked @ darin
steven spielberg
@steven - it works fine. Darin's example is correct, make sure you're using double quotes `"` and NOT single quotes `'`.
GenericTypeTea