开发者

Literal character in C#

开发者 https://www.devze.com 2023-01-11 06:42 出处:网络
I want 开发者_开发百科to compile my C# code. I was parsing a string by \"....\", string[] parts = line.Split(new[] { \'....\' }, 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?


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

Split using string instead:

string[] parts = line.Split("....", 2);


Try using the Split method:

string[] parts = line.Split("....", 2, StringSplitOptions.None);
0

精彩评论

暂无评论...
验证码 换一张
取 消