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 Stri
I know you asked about C#, but if you're willing to use any .Net language then I highly recommend Visual Basic for this exact problem. Visual Basic has a feature called XML Literals that will allow you to write code like this.
Module Module1
Sub Main()
Dim myTitle = "Hello HTML"
Dim myHTML =
<%= myTitle %>
Welcome
ID Name
1 CouldBeAVariable
Console.WriteLine(myHTML)
End Sub
End Module
This allows you to write straight HTML with expression holes in the old ASP style and makes your code super readable. Unfortunately this feature is not in C#, but you could write a single module in VB and add it as a reference to your C# project.
Writing in Visual Studio also allows proper indentation for most XML Literals and expression wholes. Indentation for the expression holes is better in VS2010.