語言

XElement.LastAttribute 屬性

定義

獲得該元素的最後一個屬性。

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

屬性值

一個 XAttribute 包含該元素最後一個屬性的 。

範例

以下範例建立包含三個屬性的 XML 樹。 接著它會把最後一個屬性寫入為輸出。

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

此範例會產生下列輸出:

Att3="3"

備註

屬性依加入元素的順序儲存在元素中。

適用於

另請參閱