开发者

Error when splitting string with string

How can I split a string with a string?

string PostBuffer = "This Is First----WebKitFormBoundaryBBZbLlWzO0CIcUa6This Is Last"
string[] bufferarray = 开发者_JAVA百科 PostBuffer.Split("----WebKitFormBoundaryBBZbLlWzO0CIcUa6", StringSplitOptions.None);

I get and error cannot convert Argument '1' from string to char and I get Argument '2' cannot convert from system.stringsplitoptions to char.

What am I doing wrong?


PostBuffer.Split(new string[] { "----WebKitFormBoundaryBBZbLlWzO0CIcUa6"}, StringSplitOptions.None);


This is because the first argument is:

Type: System.String() An array of strings that delimit the substrings in this string, an empty array that contains no delimiters, or Nothing.

So you need to do:

string[] bufferarray = 
PostBuffer.Split(new string[] { "----WebKitFormBoundaryBBZbLlWzO0CIcUa6" }, StringSplitOptions.None);

You can read more from the docs.


There is no overload for string.Split which takes a string and StringSplitOptions as arguments. Do this instead:

string[] bufferarray = 
PostBuffer.Split(new string[] { "----WebKitFormBoundaryBBZbLlWzO0CIcUa6" }, StringSplitOptions.None);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜