語言

QueryStringConverter.CanConvert(Type) 方法

定義

判斷指定型別是否能轉換為字串表示與字串表示。

public:
 virtual bool CanConvert(Type ^ type);
public virtual bool CanConvert(Type type);
abstract member CanConvert : Type -> bool
override this.CanConvert : Type -> bool
Public Overridable Function CanConvert (type As Type) As Boolean

參數

type
Type

那個 Type 要轉換。

傳回

一個指定是否能轉換型別的值。

範例

以下程式碼說明如何判斷是否 QueryStringConverter 能轉換到指定型別與該型別。

if (converter.CanConvert(typeof(Int32)))
    converter.ConvertStringToValue("123", typeof(Int32));
If (converter.CanConvert(GetType(Int32))) Then
    converter.ConvertStringToValue("123", GetType(Int32))
End If

適用於