How can I split a string using a string delimeter?
I’ve tried:
string[] htmlItems = correctHtml.Split("<tr");
I get the error:
Cannot convert from 'string' to 'char[]'
What’s the recommended way to split a string on a given string parameter?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is a version of
string.Splitthat takes a string array and an options parameter:so even though you only have one separator you want to split on you still have to pass it as an array.
Taking Mike Hofer’s answer as a starting point, this extension method will make it a bit simpler to use.