QueryStringConverter.ConvertStringToValue(String, Type) Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Convertit un paramètre de chaîne de requête en type spécifié.
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
Paramètres
- parameter
- String
Forme de chaîne du paramètre et de la valeur.
Retours
Paramètre converti.
Exceptions
La chaîne fournie n’a pas le format correct.
Exemples
Le code suivant montre comment convertir une chaîne en type spécifié.
if (converter.CanConvert(typeof(Int32)))
converter.ConvertStringToValue("123", typeof(Int32));
If (converter.CanConvert(GetType(Int32))) Then
converter.ConvertStringToValue("123", GetType(Int32))
End If
Remarques
Si la parameterType valeur est un type valeur et que le paramètre est null, la valeur par défaut de l’objet parameterType est retournée.