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 w  w .  j  a  v  a  2 s .c  o m*/
{
    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