TimeSpanMinutesConverter.ConvertTo(ITypeDescriptorContext, CultureInfo, Object, Type) TimeSpanMinutesConverter.ConvertTo(ITypeDescriptorContext, CultureInfo, Object, Type) TimeSpanMinutesConverter.ConvertTo(ITypeDescriptorContext, CultureInfo, Object, Type) 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);
abstract member ConvertTo : System.ComponentModel.ITypeDescriptorContext * System.Globalization.CultureInfo * obj * Type -> obj
override this.ConvertTo : System.ComponentModel.ITypeDescriptorContext * System.Globalization.CultureInfo * obj * Type -> obj

Parameters

ci
CultureInfo CultureInfo CultureInfo

The CultureInfo object used during conversion.

value
Object Object Object

The value to convert to.

type
Type 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