QueryStringConverter.CanConvert(Type) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
判斷指定型別是否能轉換為字串表示與字串表示。
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
參數
傳回
一個指定是否能轉換型別的值。
範例
以下程式碼說明如何判斷是否 QueryStringConverter 能轉換到指定型別與該型別。
if (converter.CanConvert(typeof(Int32)))
converter.ConvertStringToValue("123", typeof(Int32));
If (converter.CanConvert(GetType(Int32))) Then
converter.ConvertStringToValue("123", GetType(Int32))
End If