CSharp - Creating Comments with XComment

Introduction

XML comments are implemented in XComment class.

You can create a comment and add it to its element on the fly using functional construction.

Demo

using System;
using System.Linq;
using System.Xml.Linq;
using System.Collections.Generic;

class Program//from www.ja  v a2  s .  c  o m
{
    static void Main(string[] args){
          XElement xBook = new XElement("Book",
                             new XComment("This person is retired."));
    
          Console.WriteLine(xBook);
    }
}

Result

Related Topics