-3

I have the following HTML script

<h1>
 This is heading one
</h1>
<p>
 This is paragraph.
</p>

Now I want to seek your kind suggestions to add <html></html> in the above script using C#.

5
  • Are you using asp.net? Commented Feb 12, 2014 at 8:45
  • Check this stackoverflow.com/questions/1004776/write-html-in-c-sharp Commented Feb 12, 2014 at 8:45
  • 1
    Do you have the HTML in a text file that you want to edit using C#, or is this just held in a string? Can you show us what you've tried and the specific problem you've encountered? Commented Feb 12, 2014 at 8:45
  • You should include (more) code. Commented Feb 12, 2014 at 8:45
  • This question may attracts lot of negative points, because you are not specifying the exact issue or requirement. Paste some code and reply to the comments may help SO users to contribute more solutions. Also this is a simple thing may be goggling can help you to figure this. Commented Feb 12, 2014 at 8:52

3 Answers 3

4

You can use a StringBuilder to achieve this also:

var stringBuilder = new StringBuilder();
stringBuilder.Append("<html>");
stringBuilder.AppendLine(<yourString>);
stringBuilder.AppendLine("</html>");
//to get the html use
var formatedHtml = stringBuilder.ToString();

Hope this helps,

Mishu

Sign up to request clarification or add additional context in comments.

Comments

2

You mean something like this?

 string script = @"< h1>
                            This is heading one
                            < /h1>
                            < p>
                             This is paragraph.
                            < /p>";
        string sciptAfter = "<html>" + script + "</html>";

Comments

0
string text = "your html code";
text = "<html>" + Environment.NewLine + text + Environment.Newline + "</html>";

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.