XPathItem.ValueAs 方法
定义
按照指定的类型返回该项的值。Returns the item's value as the specified type.
重载
| ValueAs(Type) |
按照指定的类型返回该项的值。Returns the item's value as the specified type. |
| ValueAs(Type, IXmlNamespaceResolver) |
当在派生类中重写时,以指定用于解析命名空间前缀的 IXmlNamespaceResolver 对象所指定的类型返回项值。When overridden in a derived class, returns the item's value as the type specified using the IXmlNamespaceResolver object specified to resolve namespace prefixes. |
ValueAs(Type)
按照指定的类型返回该项的值。Returns the item's value as the specified type.
public:
virtual System::Object ^ ValueAs(Type ^ returnType);
public virtual object ValueAs (Type returnType);
abstract member ValueAs : Type -> obj
override this.ValueAs : Type -> obj
Public Overridable Function ValueAs (returnType As Type) As Object
参数
- returnType
- Type
返回的项值的类型。The type to return the item value as.
返回
以所请求类型表示的项值。The value of the item as the type requested.
例外
项值的目标类型的格式不正确。The item's value is not in the correct format for the target type.
试图进行的强制转换无效。The attempted cast is not valid.
尝试进行的强制转换导致溢出。The attempted cast resulted in an overflow.
注解
当在派生类中重写时, ValueAs 方法尝试将项的值转换为指定的 .NET Framework 2.0 类型。When overridden in a derived class, the ValueAs method attempts to convert the value of the item to the .NET Framework 2.0 type specified.
适用于
ValueAs(Type, IXmlNamespaceResolver)
当在派生类中重写时,以指定用于解析命名空间前缀的 IXmlNamespaceResolver 对象所指定的类型返回项值。When overridden in a derived class, returns the item's value as the type specified using the IXmlNamespaceResolver object specified to resolve namespace prefixes.
public:
abstract System::Object ^ ValueAs(Type ^ returnType, System::Xml::IXmlNamespaceResolver ^ nsResolver);
public abstract object ValueAs (Type returnType, System.Xml.IXmlNamespaceResolver? nsResolver);
public abstract object ValueAs (Type returnType, System.Xml.IXmlNamespaceResolver nsResolver);
abstract member ValueAs : Type * System.Xml.IXmlNamespaceResolver -> obj
Public MustOverride Function ValueAs (returnType As Type, nsResolver As IXmlNamespaceResolver) As Object
参数
- returnType
- Type
返回的项值的类型。The type to return the item's value as.
- nsResolver
- IXmlNamespaceResolver
用于解析命名空间前缀的 IXmlNamespaceResolver 对象。The IXmlNamespaceResolver object used to resolve namespace prefixes.
返回
以所请求类型表示的项值。The value of the item as the type requested.
例外
项值的目标类型的格式不正确。The item's value is not in the correct format for the target type.
试图进行的强制转换无效。The attempted cast is not valid.
尝试进行的强制转换导致溢出。The attempted cast resulted in an overflow.
注解
当在派生类中重写时, ValueAs 方法尝试将项的值转换为指定的 .NET Framework 2.0 类型。When overridden in a derived class, the ValueAs method attempts to convert the value of the item to the .NET Framework 2.0 type specified.
IXmlNamespaceResolver对象用于解析与类型转换相关的命名空间前缀。The IXmlNamespaceResolver object is used to resolve namespace prefixes related to type conversions. 例如,将转换为时 xs:QName xs:string 。For example, when converting an xs:QName to an xs:string.
有关命名空间中的类型支持的详细信息 System.Xml ,请参阅 System.Xml 类中的类型支持。For more information about type support in the System.Xml namespace, see Type Support in the System.Xml Classes.