TypeConverter.CanConvertTo Method (ITypeDescriptorContext, Type)


Returns whether this converter can convert the object to the specified type, using the specified context.

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

public virtual bool CanConvertTo(
	ITypeDescriptorContext context,
	Type destinationType


Type: System.ComponentModel.ITypeDescriptorContext

An ITypeDescriptorContext that provides a format context.

Type: System.Type

A Type that represents the type you want to convert to.

Return Value

Type: System.Boolean

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

Use the context parameter to extract additional information about the environment from which this converter is invoked. This parameter can be null, so always check it. Also, properties on the context object can return null.

If destinationType is a string, the default implementation of CanConvertTo always returns true.

Notes to Inheritors:

Override this method to provide your own conversion requirements.

.NET Framework
Available since 1.1
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top