DateTime.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 DateTime object to an object of a specified type.
Assembly: mscorlib (in mscorlib.dll)
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.ObjectAn object of the type specified by the type parameter, with a value equivalent to the current DateTime object.
Implements
IConvertible.ToType(Type, IFormatProvider)| Exception | Condition |
|---|---|
| ArgumentNullException | type is null. |
| InvalidCastException | This conversion is not supported for the DateTime type. |
Show: