Language

QueryStringConverter.ConvertStringToValue(String, Type) メソッド

定義

クエリ文字列パラメーターを指定した型に変換します。

public:
 virtual System::Object ^ ConvertStringToValue(System::String ^ parameter, Type ^ parameterType);
public virtual object ConvertStringToValue(string parameter, Type parameterType);
abstract member ConvertStringToValue : string * Type -> obj
override this.ConvertStringToValue : string * Type -> obj
Public Overridable Function ConvertStringToValue (parameter As String, parameterType As Type) As Object

パラメーター

parameter
String

パラメーターと値の文字列形式。

parameterType
Type

パラメーターを変換する Type 。

返品

変換されたパラメーター。

例外

指定された文字列の形式が正しくありません。

例

次のコードは、文字列を指定した型に変換する方法を示しています。

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

注釈

parameterTypeが値型で、パラメーターがnull場合は、parameterTypeの既定値が返されます。

適用対象