Tengo un código como este. ¿Hay alguna forma de facilitar la escritura y el mantenimiento? Utilizando C# .NET 3,5Escribir html en C#
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}", "");
}
operación -Editar- que no sabía entonces, pero que podría escribir
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");
y funcionará pero que tenga que reemplazar todos "con ''
Es bueno que relize esto es una mala manera de hacer un archivo HTML utilizando un programa. – Kredns
duplicado: http://stackoverflow.com/questions/937201 http://stackoverflow.com/questions/897226 http://stackoverflow.com/questions/340095 http://stackoverflow.com/questions/346449 –
por qué usar el '{0}' en absoluto? Excepto por el título, no lo necesitas. Puedes simplemente poner tu cadena como primer argumento y no usar un segundo argumento. –