This documentation is archived and is not being maintained.

ConfigurationConverterBase.CanConvertTo Method (ITypeDescriptorContext, Type)

Determines whether the conversion is allowed.

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

public override bool CanConvertTo (
	ITypeDescriptorContext ctx,
	Type type
public boolean CanConvertTo (
	ITypeDescriptorContext ctx, 
	Type type
public override function CanConvertTo (
	ctx : ITypeDescriptorContext, 
	type : Type
) : boolean
Not applicable.



The ITypeDescriptorContext object used for type conversion.


The type to convert to.

Return Value

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 override bool CanConvertTo(
    ITypeDescriptorContext ctx, Type type)
    return (type == typeof(string));

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0