DBNull.IConvertible.ToType Method

This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Converts the current DBNull object to the specified type.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

Syntax

Private Function ToType ( _
    type As Type, _
    provider As IFormatProvider _
) As Object Implements IConvertible.ToType
Object IConvertible.ToType(
    Type type,
    IFormatProvider provider
)

Parameters

  • provider
    Type: System..::.IFormatProvider
    An object that implements the IFormatProvider interface and is used to augment the conversion. If nullNothingnullptra null reference (Nothing in Visual Basic) is specified, format information is obtained from the current culture.

Return Value

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

Implements

IConvertible..::.ToType(Type, IFormatProvider)

Exceptions

Exception Condition
InvalidCastException

This conversion is not supported for the DBNull type.

ArgumentNullException

type is nullNothingnullptra null reference (Nothing in Visual Basic).

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.

Version Information

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Platforms

Windows Phone

See Also

Reference

DBNull Class

System Namespace

Type

IConvertible