Export (0) Print
Expand All

TimeSpanMinutesConverter.ConvertFrom Method (ITypeDescriptorContext, CultureInfo, Object)

Converts a String to a TimeSpan.

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

public override Object ConvertFrom(
	ITypeDescriptorContext ctx,
	CultureInfo ci,
	Object data


Type: System.ComponentModel.ITypeDescriptorContext

The ITypeDescriptorContext object used for type conversions.

Type: System.Globalization.CultureInfo

The CultureInfo object used during conversion.

Type: System.Object

The String object to convert.

Return Value

Type: System.Object
The TimeSpan representing the data parameter in minutes.

The system uses the ConvertFrom method when reading from a configuration file to convert a String value to TimeSpan.

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

public override object ConvertFrom(
    ITypeDescriptorContext ctx, CultureInfo ci, object data)

    long min = long.Parse((string)data,

    return TimeSpan.FromMinutes((double)min);

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft