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);
精彩评论