TypeConverter.CanConvertTo 方法

定义

返回此转换器是否可将该对象转换为指定的类型。

重载

CanConvertTo(Type)

返回此转换器是否可将该对象转换为指定的类型。

CanConvertTo(ITypeDescriptorContext, Type)

返回此转换器能否使用指定上下文将对象转换为指定类型。

CanConvertTo(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

参数

destinationType
Type

一个 Type,表示你希望转换为的类型。

返回

Boolean

如果该转换器能够执行转换,则为 true;否则为 false

注解

如果destinationType为字符串,则始终返回true默认实现CanConvertTo

适用于

CanConvertTo(ITypeDescriptorContext, Type)

返回此转换器能否使用指定上下文将对象转换为指定类型。

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

参数

context
ITypeDescriptorContext

一个 ITypeDescriptorContext,用于提供格式上下文。

destinationType
Type

一个 Type,表示你希望转换为的类型。

返回

Boolean

如果该转换器能够执行转换,则为 true;否则为 false

注解

使用 context 参数提取有关调用此转换器的环境的附加信息。 此参数可以是 null,因此请始终检查它。 同样,上下文对象的属性可以返回 null

如果destinationType为字符串,则始终返回true默认实现CanConvertTo

继承者说明

重写该方法以提供您自己的转换要求。

另请参阅

适用于