TypeConverter.CanConvertTo Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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)
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
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)
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.
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
反馈
https://aka.ms/ContentUserFeedback。
即将推出:在整个 2024 年,我们将逐步取消以“GitHub 问题”作为内容的反馈机制,并将其替换为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈