語言

ValueSerializer.GetConvertToException(Object, Type) 方法

定義

當無法執行轉換時,回傳一個例外以拋出。

protected:
 Exception ^ GetConvertToException(System::Object ^ value, Type ^ destinationType);
protected Exception GetConvertToException(object value, Type destinationType);
member this.GetConvertToException : obj * Type -> Exception
Protected Function GetConvertToException (value As Object, destinationType As Type) As Exception

參數

value
Object

那個無法轉換的物件。

destinationType
Type

一個代表轉換嘗試轉換的類型。

傳回

Exception當無法執行轉換時,例外會拋出ConvertTo一個物件。

備註

此方法不會呼叫實際 throw 關鍵字,因此典型用法為 throw GetConvertToException (參數 value 提供)。

回傳的特定例外為 InvalidOperationException,例外 value 訊息中已傳遞。 使用模式與例外工具相同。TypeConverter

適用於