.NET Framework Class Library
XElement.HasElements Property
Gets a value indicating whether this element has at least one child element.
Assembly: System.Xml.Linq (in System.Xml.Linq.dll)
Syntax
Visual Basic
Public ReadOnly Property HasElements As Boolean Get
C#
public bool HasElements { get; }
Visual C++
public: property bool HasElements { bool get (); }
F#
member HasElements : bool
Property Value
Type: System.Booleantrue if this element has at least one child element; otherwise false.
Examples
The following example uses this property.
C#
XElement xmlTree1 = new XElement("Root", new XElement("Child", 1) ); Console.WriteLine(xmlTree1.HasElements); XElement xmlTree2 = new XElement("Root", "contents"); Console.WriteLine(xmlTree2.HasElements);
Visual Basic
Dim xmlTree1 As XElement = _ <Root> <Child>1</Child> </Root> Console.WriteLine(xmlTree1.HasElements) Dim xmlTree2 As XElement = <Root>contents</Root> Console.WriteLine(xmlTree2.HasElements)
This example produces the following output:
True False
Version Information
.NET Framework
Supported in: 4, 3.5.NET Framework Client Profile
Supported in: 4, 3.5 SP1Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
See Also