XmlReader.ReadContentAsDecimal XmlReader.ReadContentAsDecimal XmlReader.ReadContentAsDecimal XmlReader.ReadContentAsDecimal Method

定义

将当前位置的文本内容作为 Decimal 对象读取。Reads the text content at the current position as a Decimal object.

public:
 virtual System::Decimal ReadContentAsDecimal();
public virtual decimal ReadContentAsDecimal ();
abstract member ReadContentAsDecimal : unit -> decimal
override this.ReadContentAsDecimal : unit -> decimal
Public Overridable Function ReadContentAsDecimal () As Decimal

返回

作为 Decimal 对象的当前位置的文本内容。The text content at the current position as a Decimal object.

异常

试图进行的强制转换无效。The attempted cast is not valid.

该字符串格式无效。The string format is not valid.

在上一次异步操作完成之前调用了 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."

注解

此方法连接文本、空格、有效空白和 CDATA 部分,并跳过任何注释或处理指令。This method concatenates text, white space, significant white space, and CDATA sections, and skips any comments or processing instructions. 实体引用会自动得到解决。Entity references are automatically resolved.

如果内容是类型化xsd:decimal的,则读取器将Decimal返回取消装箱的对象。If the content is typed xsd:decimal, the reader returns an unboxed Decimal object. 如果未键入xsd:decimal内容,读取器将尝试根据W3C XML 架构第 2 Decimal部分定义的规则将其转换为对象:数据类型建议。If the content is not typed xsd:decimal, the reader attempts to convert it to a Decimal object according to the rules defined by the W3C XML Schema Part 2: Datatypes recommendation.

下表描述了此方法如何处理每个节点类型。The following table describes how this method treats each node type.

XmlNodeTypeXmlNodeType 返回值Return value 读取器行为Reader behavior
Text

CDATA

Whitespace

SignificantWhitespace

EntityReference

EndEntity
将文本、CDATA、空白和有效空白节点的串联内容转换为所请求的类型。Concatenated content of text, CDATA, white space and significant white space nodes converted to the requested type. 移至下一个开始元素或结束元素标记。Moves to the next start element or end element tag. 实体引用自动展开。Entity references are automatically expanded.
Attribute 与对属性XmlConvert.ToXxx值调用相同。Same as calling XmlConvert.ToXxx on the attribute value. 读取器仍保留在当前位置。The reader remains in the current position.
Comment

ProcessingInstruction
忽略处理指令 (PI) 或注释,读取 PI 或注释后面的串联文本内容。Ignores the processing instruction (PI) or comment and reads the concatenated text content that follows the PI or comment. 移至下一个开始元素或结束元素标记。Moves to the next start element or end element tag. 实体引用自动展开。Entity references are automatically expanded.
EndElement 空字符串。An empty string. 读取器仍保留在当前位置。The reader remains in the current position.
Element

XmlDeclaration

None

Document

DocumentType

Notation

Entity

DocumentFragment
引发 InvalidOperationExceptionAn InvalidOperationException is thrown. 未定义,尽管通常读取器将保留在当前位置。Undefined, although typically the reader remains in the current position.

有关详细信息,请参阅XmlReader参考页和 W3C XML 架构第2部分:数据类型建议。For more information, see the XmlReader reference page and the W3C XML Schema Part 2: Datatypes recommendation.

适用于