I have code like this. Is there a way to make it easier to write and maintain?
Using 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}", "");
}
I could also just write:
s.WriteLine("{0}", @"blah blah
many
new
lines
blah UHY#$&_#$_*@Y KSDSD<>t\\hh'h'th
hi
done");
It will work, but I need to replace all "
with ""
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…