Asp.net .NET Replace()没有´;行不通

Asp.net .NET Replace()没有´;行不通,asp.net,replace,Asp.net,Replace,嗨,我正在将aspx文件解析为XML,我有以下代码: if (lineLower.StartsWith("</asp:content>")) || (lineLower.StartsWith("</asp:Content>") && lineLower.EndsWith(">"))) { temp +

嗨,我正在将aspx文件解析为XML,我有以下代码:

if (lineLower.StartsWith("</asp:content>")) || (lineLower.StartsWith("</asp:Content>") && lineLower.EndsWith(">")))
                                    {
                                        temp += line.Replace(line, " ");
                                    }
if(lineLower.StartsWith(“”)| |(lineLower.StartsWith(“”)&&lineLower.EndsWith(“”))
{
温度+=行。替换(行“”);
}
但是这个temp+=行。替换(行“”将只在之前添加一个空格,而不是用空格替换

我需要使用不同的语法吗?

首先,您有这个

if (lineLower.StartsWith("</asp:content>"))

你把它编得太复杂了

只要这样做:

if (line.ToLower().StartsWith("</asp:content>") && line.EndsWith(">")))
{
    temp += " ";
}
if(line.ToLower()
{
温度+=”;
}

甚至不确定您是否需要此部分:line.EndsWith(“>”)

您到底想要实现什么?您的IF逻辑看起来不稳定,根据LeZohan68的回答,这甚至不会编译。您不使用实际的XML解析器的任何原因,例如?也不是
temp+=line.Replace(line,”)
temp+=”完全相同
if (line.ToLower().StartsWith("</asp:content>") && line.EndsWith(">")))
{
    temp += " ";
}