Editar

Compartilhar via


TimeSpanMinutesConverter.ConvertTo Method

Definition

Converts a TimeSpan to a String.

public:
 override System::Object ^ ConvertTo(System::ComponentModel::ITypeDescriptorContext ^ ctx, System::Globalization::CultureInfo ^ ci, System::Object ^ value, Type ^ type);
public override object ConvertTo (System.ComponentModel.ITypeDescriptorContext ctx, System.Globalization.CultureInfo ci, object value, Type type);
override this.ConvertTo : System.ComponentModel.ITypeDescriptorContext * System.Globalization.CultureInfo * obj * Type -> obj
Public Overrides Function ConvertTo (ctx As ITypeDescriptorContext, ci As CultureInfo, value As Object, type As Type) As Object

Parameters

ctx
ITypeDescriptorContext

The ITypeDescriptorContext object used for type conversions.

ci
CultureInfo

The CultureInfo object used during conversion.

value
Object

The value to convert to.

type
Type

The type to convert to.

Returns

The String representing the value parameter in minutes.

Examples

The following code example shows how to customize the ConvertTo method.

public override object ConvertTo(
    ITypeDescriptorContext ctx, CultureInfo ci,
    object value, Type type)
{
    ValidateType(value, typeof(TimeSpan));

    long data = (long)(((TimeSpan)value).TotalMinutes);

    return data.ToString(CultureInfo.InvariantCulture);
}
Public Overrides Function ConvertTo( _
ByVal ctx As ITypeDescriptorContext, _
ByVal ci As CultureInfo, ByVal value As Object, _
ByVal type As Type) As Object
    ValidateType(value, GetType(TimeSpan))

    Dim data As Long = _
    Fix(CType(value, TimeSpan).TotalMinutes)

    Return data.ToString(CultureInfo.InvariantCulture)

End Function 'ConvertTo

Remarks

The system uses the ConvertTo method when writing to a configuration file to convert a TimeSpan to a String.

Applies to