PointConverter.ConvertTo(ITypeDescriptorContext, CultureInfo, Object, Type) Method

Definition

将指定的对象转换成指定的类型。Converts the specified object to the specified type.

public:
 override System::Object ^ ConvertTo(System::ComponentModel::ITypeDescriptorContext ^ context, System::Globalization::CultureInfo ^ culture, System::Object ^ value, Type ^ destinationType);
public override object ConvertTo (System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType);
override this.ConvertTo : System.ComponentModel.ITypeDescriptorContext * System.Globalization.CultureInfo * obj * Type -> obj
Public Overrides Function ConvertTo (context As ITypeDescriptorContext, culture As CultureInfo, value As Object, destinationType As Type) As Object

Parameters

context
ITypeDescriptorContext

格式化程序上下文。A formatter context. 此对象可用于获取有关从中调用此转换器的环境的附加信息。This object can be used to get additional information about the environment this converter is being called from. 这可能为 null,因此应总是对其进行检查。This may be null, so you should always check. 同样,上下文对象上的属性也可能返回 nullAlso, properties on the context object may also return null.

culture
CultureInfo

包含区域性特定信息(如语言、日历和与特定区域性关联的区域性约定)的对象。An object that contains culture specific information, such as the language, calendar, and cultural conventions associated with a specific culture. 它基于 RFC 1766 标准。It is based on the RFC 1766 standard.

value
Object

要转换的对象。The object to convert.

destinationType
Type

对象要转换为的类型。The type to convert the object to.

Returns

Object

转换后的对象。The converted object.

Exceptions

无法完成转换。The conversion cannot be completed.

Remarks

最常见的转换类型是与字符串对象的相互转换。The most common types to convert are to and from a string object. 如果对象有效并且目标类型为 string,则默认实现将调用对象的 ToString 方法。The default implementation calls the object's ToString method if the object is valid and if the destination type is string. 如果此方法无法转换为目标类型,则会引发 NotSupportedException 异常。If this method cannot convert to the destination type, this will throw a NotSupportedException exception.

Applies to