Create a new instance of the XDocument and add XComment and XElement
using System; using System.Linq; using System.Xml.Linq; using System.Collections; using System.Collections.Generic; public class MainClass{ public static void Main(){ XDocument doc = new XDocument(); doc.Add(new XComment("This is a comment")); doc.Add(new XElement("Root", "content")); Console.WriteLine(doc); } }