XElement.FirstAttribute 屬性

定義

取得這個元素的第一個屬性。

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

屬性值

XAttribute,包含這個項目的第一個屬性。

範例

下列範例會使用這個屬性。

XElement xmlTree = new XElement("Root",
    new XAttribute("Att1", 1),
    new XAttribute("Att2", 2),
    new XAttribute("Att3", 3)
);
Console.WriteLine(xmlTree.FirstAttribute);
Dim xmlTree As XElement = <Root Att1="1" Att2="2" Att3="3"/>
Console.WriteLine(xmlTree.FirstAttribute)

這個範例會產生下列輸出:

Att1="1"

備註

屬性會以新增至 元素的順序儲存在 元素中。

適用於

另請參閱