CSharp - Deferred Execution of the XML Tree Construction by Using the XStreamingElement Class

Description

Deferred Execution of the XML Tree Construction by Using the XStreamingElement Class

Demo

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

class Program/*from w  ww  . ja va2  s.  c  om*/
{
    static void Main(string[] args){
        string[] names = { "Python", "Java", "C++", "Oracle" };
        
        XStreamingElement xNames =
          new XStreamingElement("Beatles",
                                from n in names
                                select new XStreamingElement("Name", n));
        
        names[3] = "Ringo";
        
        Console.WriteLine(xNames);
    }
}

Result

Related Topic