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

定义

将当前 DateTime 对象转换为指定类型的对象。Converts the current DateTime object to an object of a specified type.

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

参数

type
Type Type

所需类型。The desired type.

provider
IFormatProvider IFormatProvider

一个实现 IFormatProvider 接口的对象。An object that implements the IFormatProvider interface. (未使用此参数;指定 null。)(This parameter is not used; specify null.)

返回

type 参数指定的类型的对象,其值与当前 DateTime 对象等效。An object of the type specified by the type parameter, with a value equivalent to the current DateTime object.

实现

异常

typenulltype is null.

DateTime 类型不支持此转换。This conversion is not supported for the DateTime type.

适用于

另请参阅