Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

ConfigurationConverterBase.CanConvertTo Method (ITypeDescriptorContext, Type)

Note: This method is new in the .NET Framework version 2.0.

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



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 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

© 2015 Microsoft