XmlReader.ReadString XmlReader.ReadString XmlReader.ReadString XmlReader.ReadString Method

定义

当在派生类中被重写时,将元素或文本节点的内容当做字符串读取。When overridden in a derived class, reads the contents of an element or text node as a string. 但是,建议改用 ReadElementContentAsString 方法,因为该方法可以更直接地处理此操作。However, we recommend that you use the ReadElementContentAsString method instead, because it provides a more straightforward way to handle this operation.

public:
 virtual System::String ^ ReadString();
public virtual string ReadString ();
abstract member ReadString : unit -> string
override this.ReadString : unit -> string
Public Overridable Function ReadString () As String

返回

元素的内容或空字符串。The contents of the element or an empty string.

异常

分析 XML 时出错。An error occurred while parsing the XML.

在上一次异步操作完成之前调用了 XmlReader 方法。An XmlReader method was called before a previous asynchronous operation finished. 在此情况下,会引发 InvalidOperationException 并显示消息“异步操作已在进行中。”In this case, InvalidOperationException is thrown with the message "An asynchronous operation is already in progress."

注解

建议使用ReadElementContentAsString方法,将元素或文本节点的内容读取为一个字符串。We recommend that you use the ReadElementContentAsString method to read the contents of an element or text node as a string.

适用于