相关疑难解决方法(0)

在C#中编写html

我有这样的代码.有没有办法让它更容易编写和维护?使用C#.NET 3.5

string header(string title)
{
    StringWriter s = new StringWriter();
    s.WriteLine("{0}","<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">");
    s.WriteLine("{0}", "<html>");
    s.WriteLine("<title>{0}</title>", title);
    s.WriteLine("{0}","<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">");
    s.WriteLine("{0}", "</head>");
    s.WriteLine("{0}", "<body>");
    s.WriteLine("{0}", "");
}
Run Code Online (Sandbox Code Playgroud)

-edit-我当时不知道但我可以写

s.WriteLine("{0}", @"blah blah

many
new
lines
blah UHY#$&_#$_*@Y KSDSD<>\t\t\t\t\t\tt\t\t\\\t\t\t\t\\\h\th'\h't\th
hi
done"); 
Run Code Online (Sandbox Code Playgroud)

它会工作,但需要更换所有"与"

html c#

45
推荐指数
8
解决办法
16万
查看次数

标签 统计

c# ×1

html ×1