QueryStringConverter.CanConvert(Type) 方法
定义
确定能否在指定类型和字符串表示形式之间进行转换。Determines whether the specified type can be converted to and from a string representation.
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
参数
返回
一个用于指定能否转换类型的值。A value that specifies whether the type can be converted.
示例
下面的代码演示如何确定 QueryStringConverter 是否可以转换为指定类型以及从指定类型转换。The following code shows how to determine whether the QueryStringConverter can convert to and from the specified type.
if (converter.CanConvert(typeof(Int32)))
converter.ConvertStringToValue("123", typeof(Int32));
If (converter.CanConvert(GetType(Int32))) Then
converter.ConvertStringToValue("123", GetType(Int32))
End If