Edit

Share via


TypeConverter.CanConvertTo Method

Definition

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

Overloads

CanConvertTo(Type)

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

CanConvertTo(ITypeDescriptorContext, Type)

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

CanConvertTo(Type)

Source:
TypeConverter.cs
Source:
TypeConverter.cs
Source:
TypeConverter.cs

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

public:
 bool CanConvertTo(Type ^ destinationType);
public bool CanConvertTo (Type destinationType);
public bool CanConvertTo (Type? destinationType);
member this.CanConvertTo : Type -> bool
Public Function CanConvertTo (destinationType As Type) As Boolean

Parameters

destinationType
Type

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

Returns

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

Remarks

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

Applies to

CanConvertTo(ITypeDescriptorContext, Type)

Source:
TypeConverter.cs
Source:
TypeConverter.cs
Source:
TypeConverter.cs

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

public:
 virtual bool CanConvertTo(System::ComponentModel::ITypeDescriptorContext ^ context, Type ^ destinationType);
public virtual bool CanConvertTo (System.ComponentModel.ITypeDescriptorContext context, Type destinationType);
public virtual bool CanConvertTo (System.ComponentModel.ITypeDescriptorContext? context, Type? destinationType);
abstract member CanConvertTo : System.ComponentModel.ITypeDescriptorContext * Type -> bool
override this.CanConvertTo : System.ComponentModel.ITypeDescriptorContext * Type -> bool
Public Overridable Function CanConvertTo (context As ITypeDescriptorContext, destinationType As Type) As Boolean

Parameters

context
ITypeDescriptorContext

An ITypeDescriptorContext that provides a format context.

destinationType
Type

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

Returns

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

Remarks

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.

See also

Applies to