In This Article

TimeSpanConverter Class

Converts TimeSpan to and from a String.

public class TimeSpanConverter : TypeConverter
Inheritance:
Object Object

Constructors

TimeSpanConverter()

public TimeSpanConverter()

Methods

CanConvertFrom(ITypeDescriptorContext, Type)

Returns whether the type converter can convert an object from the specified type to the type of this converter.

public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
Parameter Type Description
context ITypeDescriptorContext

An object that provides a format context.

sourceType Type

The type you want to convert from.

Returns

Boolean:

true if this converter can perform the conversion; otherwise, false.

CanConvertTo(ITypeDescriptorContext, Type)

Returns whether the type converter can convert an object to the specified type.

public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
Parameter Type Description
context ITypeDescriptorContext

An object that provides a format context.

destinationType Type

The type you want to convert to.

Returns

Boolean:

true if this converter can perform the conversion; otherwise, false.

ConvertFrom(ITypeDescriptorContext, CultureInfo, Object)

Converts from the specified value to the intended conversion type of the converter.

public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
Parameter Type Description
context ITypeDescriptorContext

An object that provides a format context.

culture CultureInfo

The CultureInfo to use as the current culture.

value Object

The value to convert to the type of this converter.

Returns

Object:

The converted value.

ConvertTo(ITypeDescriptorContext, CultureInfo, Object, Type)

Converts the specified value object to the specified type.

public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
Parameter Type Description
context ITypeDescriptorContext

An object that provides a format context.

culture CultureInfo

The CultureInfo to use as the current culture.

value Object

The object to convert.

destinationType Type

The type to convert the object to.

Returns

Object:

The converted object.