ConfigurationConverterBase.CanConvertTo Method (ITypeDescriptorContext, Type)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Determines whether the conversion is allowed.

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

Public Overrides Function CanConvertTo (
	ctx As ITypeDescriptorContext,
	type As Type
) As Boolean


Type: System.ComponentModel.ITypeDescriptorContext

The ITypeDescriptorContext object used for type conversion.

Type: System.Type

The type to convert to.

Return Value

Type: System.Boolean

true if the conversion is allowed; otherwise, false.

The CanConvertFrom method determines whether the strings contained in the configuration file can be converted to the related strongly typed properties.

The following example code shows how to override the CanConvertFrom method to create a custom TimeSpan converter type. Also, the example shows how to use this type in a custom section.

Public Overrides Function CanConvertTo( _
ByVal ctx As ITypeDescriptorContext, _
ByVal type As Type) As Boolean
    Return (type.ToString() = GetType(String).ToString())

End Function 'CanConvertTo

.NET Framework
Available since 2.0
Return to top