CSharp - Creating a Comment and Adding It to Its Element

Description

Creating a Comment and Adding It to Its Element

Demo

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

class Program/*from   ww  w  . j a va2 s .co m*/
{
    static void Main(string[] args){
      XElement xBook = new XElement("Book");
      XComment xComment = new XComment("This person is retired.");
      xBook.Add(xComment);

      Console.WriteLine(xBook);
    }
}

Result

Related Topic