我被困在PHP函数转换为C#!将函数PHP转换为C#
有人可以告诉我我做得不好吗?
原代码(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);
}
我的代码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;
}
}
我希望有人能帮助我,我很坚持!
这里你的问题到底是什么?是否编译?你有错误吗?任何意外的结果? – HimBromBeere
发生了什么事不正确?我注意到你错过了C#代码中PHP函数的最后两行代码。另外,我只是把它放在那里,'end'是C#中的一个保留字。尝试重命名你的最终变量为别的东西。 – RToyo
请阅读\t https://meta.stackoverflow.com/questions/284236/why-is-can-someone-help-me-not-an-actual-question。我们需要明确的问题陈述(另请参见[mcve])。 – GhostCat