DateTime.IConvertible.ToType Method (Type, IFormatProvider)

 

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

Converts the current DateTime object to an object of a specified type.

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

private abstract ToType : 
        type:Type *
        provider:IFormatProvider -> Object
private override ToType : 
        type:Type *
        provider:IFormatProvider -> Object

Parameters

type
Type: System.Type

The desired type.

provider
Type: System.IFormatProvider

An object that implements the IFormatProvider interface. (This parameter is not used; specify null.)

Return Value

Type: System.Object

An object of the type specified by the type parameter, with a value equivalent to the current DateTime object.

Exception Condition
ArgumentNullException

type is null.

InvalidCastException

This conversion is not supported for the DateTime type.

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
Show: