共用方式為


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

適用於