XElement.HasAttributes 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
會得到一個值,表示該元素是否至少有一個屬性。
public:
property bool HasAttributes { bool get(); };
public bool HasAttributes { get; }
member this.HasAttributes : bool
Public ReadOnly Property HasAttributes As Boolean
屬性值
true 如果該元素至少有一個屬性;否則 false。
範例
以下範例使用了此性質。
XElement xmlTree1 = new XElement("Root",
new XAttribute("Att1", 1)
);
Console.WriteLine(xmlTree1.HasAttributes);
XElement xmlTree2 = new XElement("Root");
Console.WriteLine(xmlTree2.HasAttributes);
Dim xmlTree1 As XElement = <Root Att1="1"/>
Console.WriteLine(xmlTree1.HasAttributes)
Dim xmlTree2 As XElement = <Root/>
Console.WriteLine(xmlTree2.HasAttributes)
此範例會產生下列輸出:
True
False