XContainer.LastNode Property


Gets the last child node of this node.

 property System::Xml::Linq::XNode ^ LastNode { System::Xml::Linq::XNode ^ get(); };
public System.Xml.Linq.XNode LastNode { get; }
member this.LastNode : System.Xml.Linq.XNode
Public ReadOnly Property LastNode As XNode

Property Value

An XNode containing the last child node of the XContainer.


The following example creates an element that contains child elements. It then gets the last child node of the parent element.

XElement xmlTree = new XElement("Root",  
    new XElement("Child1", 1),  
    new XElement("Child2", 2),  
    new XElement("Child3", 3),  
    new XElement("Child4", 4),  
    new XElement("Child5", 5)  
XNode lastNode = xmlTree.LastNode;  
Dim xmlTree As XElement = _   
Dim lastNode As XNode = xmlTree.LastNode  

This example produces the following output:


Applies to

See also