I am stuck in a convertion of PHP function to C#!
Someone can tell me what I am doing bad?
Original code (PHP):
function delete_all_between($beginning, $end, $string)
{
$beginningPos = strpos($string, $beginning);
$endPos = strpos($string, $end);
if ($beginningPos === false || $endPos === false) {
return $string;
}
$textToDelete = substr($string, $beginningPos, ($endPos + strlen($end)) - $beginningPos);
return str_replace($textToDelete, '', $string);
}
My code C#:
string delete_all_between(string beginning, string end, string html)
{
int beginningPos = html.IndexOf(beginning);
int endPos = html.IndexOf(end);
if (beginningPos == -1 || endPos == -1)
{
return html;
}
}
I hope someone can help me, I am really stuck!
endis a reserved word in C#. Try rename your end variable to something else.