XmlSchemaDatatype.ChangeType Method

Definition

Converts the value specified, whose type is one of the valid Common Language Runtime (CLR) representations of the XML schema type represented by the XmlSchemaDatatype, to another valid CLR representation of the same value.

Overloads

ChangeType(Object, Type)

Converts the value specified, whose type is one of the valid Common Language Runtime (CLR) representations of the XML schema type represented by the XmlSchemaDatatype, to the CLR type specified.

ChangeType(Object, Type, IXmlNamespaceResolver)

Converts the value specified, whose type is one of the valid Common Language Runtime (CLR) representations of the XML schema type represented by the XmlSchemaDatatype, to the CLR type specified using the IXmlNamespaceResolver if the XmlSchemaDatatype represents the xs:QName type or a type derived from it.

ChangeType(Object, Type)

Source:
XmlSchemaDataType.cs
Source:
XmlSchemaDataType.cs
Source:
XmlSchemaDataType.cs

Converts the value specified, whose type is one of the valid Common Language Runtime (CLR) representations of the XML schema type represented by the XmlSchemaDatatype, to the CLR type specified.

C#
public virtual object ChangeType(object value, Type targetType);

Parameters

value
Object

The input value to convert to the specified type.

targetType
Type

The target type to convert the input value to.

Returns

The converted input value.

Exceptions

The Object or Type parameter is null.

The type represented by the XmlSchemaDatatype does not support a conversion from type of the value specified to the type specified.

Remarks

For more information about type support in the System.Xml classes and conversion of XML data types, see the Type Support in the System.Xml Classes topic.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

ChangeType(Object, Type, IXmlNamespaceResolver)

Source:
XmlSchemaDataType.cs
Source:
XmlSchemaDataType.cs
Source:
XmlSchemaDataType.cs

Converts the value specified, whose type is one of the valid Common Language Runtime (CLR) representations of the XML schema type represented by the XmlSchemaDatatype, to the CLR type specified using the IXmlNamespaceResolver if the XmlSchemaDatatype represents the xs:QName type or a type derived from it.

C#
public virtual object ChangeType(object value, Type targetType, System.Xml.IXmlNamespaceResolver namespaceResolver);

Parameters

value
Object

The input value to convert to the specified type.

targetType
Type

The target type to convert the input value to.

namespaceResolver
IXmlNamespaceResolver

An IXmlNamespaceResolver used for resolving namespace prefixes. This is only of use if the XmlSchemaDatatype represents the xs:QName type or a type derived from it.

Returns

The converted input value.

Exceptions

The Object or Type parameter is null.

The type represented by the XmlSchemaDatatype does not support a conversion from type of the value specified to the type specified.

Remarks

For more information about type support in the System.Xml classes and conversion of XML data types, see the Type Support in the System.Xml Classes topic.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1