DBNull.IConvertible.ToType(Type, IFormatProvider) DBNull.IConvertible.ToType(Type, IFormatProvider) Method

Definition

Converts the current DBNull object to the specified type.

 virtual System::Object ^ System.IConvertible.ToType(Type ^ type, IFormatProvider ^ provider) = IConvertible::ToType;
object IConvertible.ToType (Type type, IFormatProvider provider);

Parameters

type
Type Type

The type to convert the current DBNull object to.

provider
IFormatProvider IFormatProvider

An object that implements the IFormatProvider interface and is used to augment the conversion. If null is specified, format information is obtained from the current culture.

Returns

The boxed equivalent of the current DBNull object, if that conversion is supported; otherwise, an exception is thrown and no value is returned.

Implements

Exceptions

This conversion is not supported for the DBNull type.

Remarks

Three conversions are supported: If the type parameter specifies Object or DBNull, the return value is the current DBNull object itself. If the type parameter specifies String, the return value is the string returned by the ToString method.

Applies to

See also