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

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"  

備註

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

適用於

另請參閱