using System; using System.IO; using System.Web; namespace TestApplication { class Program { static void Main(string[] args) { StringWriter stringWriter = new StringWriter(); HtmlTextWriter writer = new HtmlTextWriter(stringWriter); writer.WriteBeginTag("div"); writer.WriteAttribute("class", "container"); writer.Write("This is some content inside the div element."); writer.WriteEndTag("div"); Console.WriteLine(stringWriter.ToString()); } } }
using System; using System.IO; using System.Web.UI; namespace TestApplication { class Program { static void Main(string[] args) { StringWriter stringWriter = new StringWriter(); HtmlTextWriter writer = new HtmlTextWriter(stringWriter); writer.RenderBeginTag(HtmlTextWriterTag.Ul); writer.RenderBeginTag(HtmlTextWriterTag.Li); writer.Write("Item 1"); writer.RenderEndTag(); writer.RenderBeginTag(HtmlTextWriterTag.Li); writer.Write("Item 2"); writer.RenderEndTag(); writer.RenderEndTag(); Console.WriteLine(stringWriter.ToString()); } } }This code creates a StringWriter and an HtmlTextWriter object, renders an unordered list with two list items and their content, and then renders the closing unordered list tag using the System WriteEndTag function. The output is printed to the console. The package library for the System WriteEndTag function is System.Web.