TypeConverter.CanConvertTo Метод
Определение
Возвращает значение, указывающее, может ли этот преобразователь выполнить преобразование данного объекта к заданному типу.Returns whether this converter can convert the object to the specified type.
Перегрузки
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);
member this.CanConvertTo : Type -> bool
Public Function CanConvertTo (destinationType As Type) As Boolean
Параметры
- destinationType
- Type
Класс Type, представляющий тип, в который нужно выполнить преобразование.A Type that represents the type you want to convert to.
Возвращаемое значение
Имеет значение true
, если преобразователь может выполнить преобразование, в противном случае — значение false
.true
if this converter can perform the conversion; otherwise, false
.
Комментарии
Если destinationType
является строкой, реализация по умолчанию CanConvertTo всегда возвращает значение true
.If destinationType
is a string, the default implementation of CanConvertTo always returns true
.
Применяется к
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, предоставляющий контекст формата.An ITypeDescriptorContext that provides a format context.
- destinationType
- Type
Класс Type, представляющий тип, в который нужно выполнить преобразование.A Type that represents the type you want to convert to.
Возвращаемое значение
Имеет значение true
, если преобразователь может выполнить преобразование, в противном случае — значение false
.true
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. Свойства объекта контекста могут также возвращать значение null
.Also, properties on the context object can return null
.
Если destinationType
является строкой, реализация по умолчанию CanConvertTo всегда возвращает значение true
.If destinationType
is a string, the default implementation of CanConvertTo always returns true
.
Примечания для тех, кто наследует этот метод
Переопределите этот метод в соответствии с требованиями к преобразованию.Override this method to provide your own conversion requirements.