DBNull.IConvertible.ToType(Type, IFormatProvider) Method

Definition

Converts the current DBNull object to the specified type.

object IConvertible.ToType (Type type, IFormatProvider provider);

Parameters

type
Type

The type to convert the current DBNull object to.

provider
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.

type is null.

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

제품 버전
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 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

See also