XmlReader.MoveToFirstAttribute 方法

定义

在派生类中重写时,移动到第一个属性。

public:
 abstract bool MoveToFirstAttribute();
public abstract bool MoveToFirstAttribute();
abstract member MoveToFirstAttribute : unit -> bool
Public MustOverride Function MoveToFirstAttribute () As Boolean

返回

true 如果存在属性(读取器移动到第一个属性);否则, false (读取器的位置不会更改)。

例外

在上一个异步操作完成之前调用了一个 XmlReader 方法。 在这种情况下, InvalidOperationException 会引发消息“正在进行异步操作”。

示例

以下示例获取第一个特性的值。

reader.ReadToFollowing("book");
reader.MoveToFirstAttribute();
string genre = reader.Value;
Console.WriteLine("The genre value: " + genre);
reader.ReadToFollowing("book")
reader.MoveToFirstAttribute()
Dim genre As String = reader.Value
Console.WriteLine("The genre value: " + genre)

适用于