XElement.FirstAttribute 属性

定义

获取此元素的第一个属性。

public:
 property System::Xml::Linq::XAttribute ^ FirstAttribute { System::Xml::Linq::XAttribute ^ 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"

注解

属性以添加到元素的顺序存储在元素中。

适用于

另请参阅