TypeConverter.CanConvertTo TypeConverter.CanConvertTo TypeConverter.CanConvertTo TypeConverter.CanConvertTo Method

定义

返回此转换器是否可将该对象转换为指定的类型。Returns whether this converter can convert the object to the specified type.

重载

CanConvertTo(Type) CanConvertTo(Type) CanConvertTo(Type) CanConvertTo(Type)

返回此转换器是否可将该对象转换为指定的类型。Returns whether this converter can convert the object to the specified type.

CanConvertTo(ITypeDescriptorContext, Type) CanConvertTo(ITypeDescriptorContext, Type) CanConvertTo(ITypeDescriptorContext, Type) CanConvertTo(ITypeDescriptorContext, Type)

返回此转换器能否使用指定上下文将对象转换为指定类型。Returns whether this converter can convert the object to the specified type, using the specified context.

CanConvertTo(Type) CanConvertTo(Type) CanConvertTo(Type) CanConvertTo(Type)

返回此转换器是否可将该对象转换为指定的类型。Returns whether this converter can convert the object to the specified type.

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 Type Type

一个 Type,表示你希望转换为的类型。A Type that represents the type you want to convert to.

返回

如果该转换器能够执行转换,则为 true;否则为 falsetrue if this converter can perform the conversion; otherwise, false.

注解

如果destinationType为字符串, 则的默认CanConvertTo实现始终返回trueIf destinationType is a string, the default implementation of CanConvertTo always returns true.

CanConvertTo(ITypeDescriptorContext, Type) CanConvertTo(ITypeDescriptorContext, Type) CanConvertTo(ITypeDescriptorContext, Type) CanConvertTo(ITypeDescriptorContext, Type)

返回此转换器能否使用指定上下文将对象转换为指定类型。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);
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 ITypeDescriptorContext ITypeDescriptorContext

一个 ITypeDescriptorContext,用于提供格式上下文。An ITypeDescriptorContext that provides a format context.

destinationType
Type Type Type Type

一个 Type,表示你希望转换为的类型。A Type that represents the type you want to convert to.

返回

如果该转换器能够执行转换,则为 true;否则为 falsetrue if this converter can perform the conversion; otherwise, false.

注解

使用 context 参数提取有关调用此转换器的环境的附加信息。Use the context parameter to extract additional information about the environment from which this converter is invoked. 此参数可以是null, 因此请始终选中此参数。This parameter can be null, so always check it. 同样,上下文对象的属性可以返回 nullAlso, properties on the context object can return null.

如果destinationType为字符串, 则的默认CanConvertTo实现始终返回trueIf destinationType is a string, the default implementation of CanConvertTo always returns true.

继承者说明

重写该方法以提供您自己的转换需求。Override this method to provide your own conversion requirements.

另请参阅

适用于