CollectionConverter.ConvertTo 方法

定義

將指定的數值物件轉換成指定的目的型別。

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);
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

參數

context
ITypeDescriptorContext

提供格式內容的 ITypeDescriptorContext

culture
CultureInfo

value 所要轉換的文化特性。

value
Object

要進行轉換的 Object。 這個參數必須繼承自 ICollection

destinationType
Type

值將會轉換成這個 Type

傳回

Object,代表轉換過的值。

例外狀況

destinationTypenull

無法執行轉換作業。

備註

可以使用 context 參數來擷取環境的其他資訊,而這個轉換子就是從這個環境叫用的。 這可能是 null,所以一定要檢查。 甚至,內容物件上的屬性可能會傳回 null

注意

轉換的結果會顯示在屬性瀏覽器中。 例如,如果您要將 char 集合轉換成字串,則會顯示為 char[] collection

適用於