.NET Framework Class Library
XElement.HasAttributes Property
Gets a value indicating whether this element as at least one attribute.
Assembly: System.Xml.Linq (in System.Xml.Linq.dll)
Syntax
Visual Basic
Public ReadOnly Property HasAttributes As Boolean Get
C#
public bool HasAttributes { get; }
Visual C++
public: property bool HasAttributes { bool get (); }
F#
member HasAttributes : bool
Examples
The following example uses this property.
C#
XElement xmlTree1 = new XElement("Root", new XAttribute("Att1", 1) ); Console.WriteLine(xmlTree1.HasAttributes); XElement xmlTree2 = new XElement("Root"); Console.WriteLine(xmlTree2.HasAttributes);
Visual Basic
Dim xmlTree1 As XElement = <Root Att1="1"/> Console.WriteLine(xmlTree1.HasAttributes) Dim xmlTree2 As XElement = <Root/> Console.WriteLine(xmlTree2.HasAttributes)
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