Compartir a través de


QueryStringConverter.ConvertStringToValue(String, Type) Método

Definición

Convierte un parámetro de cadena de consulta en el tipo especificado.

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

Parámetros

parameter
String

Forma de cadena del parámetro y su valor.

parameterType
Type

Type al que se va a convertir el parámetro.

Devoluciones

El parámetro convertido.

Excepciones

La cadena suministrada no tiene el formato correcto.

Ejemplos

El código siguiente muestra cómo convertir una cadena al tipo especificado.

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

Comentarios

Si parameterType es un tipo de valor y el parámetro es null, se devuelve el valor predeterminado de parameterType.

Se aplica a