Bewerken

Delen via


BaseCompareValidator.Convert Method

Definition

Converts the specified text into an object of the specified data type.

Overloads

Convert(String, ValidationDataType, Object)

Converts the specified text into an object of the specified data type. This version of the overloaded method converts currency, double, and date values using the format used by the current culture.

Convert(String, ValidationDataType, Boolean, Object)

Converts the specified text into an object of the specified data type. This version of the overloaded method allows you to specify whether values are converted using a culture-neutral format.

Convert(String, ValidationDataType, Object)

Converts the specified text into an object of the specified data type. This version of the overloaded method converts currency, double, and date values using the format used by the current culture.

protected:
 static bool Convert(System::String ^ text, System::Web::UI::WebControls::ValidationDataType type, [Runtime::InteropServices::Out] System::Object ^ % value);
protected static bool Convert (string text, System.Web.UI.WebControls.ValidationDataType type, out object value);
static member Convert : string * System.Web.UI.WebControls.ValidationDataType * obj -> bool
Protected Shared Function Convert (text As String, type As ValidationDataType, ByRef value As Object) As Boolean

Parameters

text
String

The text to convert.

type
ValidationDataType

One of the ValidationDataType values.

value
Object

When this method returns, contains an object with the conversion result. This parameter is passed uninitialized.

Returns

true if the conversion is successful; otherwise, false.

Remarks

The Convert(String, ValidationDataType, Object) method is used to convert text into an object of the specified data type. Although the method returns true or false to indicate whether the conversion was successful, the converted value is stored in the value out parameter.

Note

If the conversion is unsuccessful, the value parameter is set to null.

This version of the method converts values using the format used by the current culture. To convert values using a culture-neutral format, use the BaseCompareValidator.Convert(String, ValidationDataType, Boolean, Object) overloaded version of this method.

See also

Applies to

Convert(String, ValidationDataType, Boolean, Object)

Converts the specified text into an object of the specified data type. This version of the overloaded method allows you to specify whether values are converted using a culture-neutral format.

protected:
 static bool Convert(System::String ^ text, System::Web::UI::WebControls::ValidationDataType type, bool cultureInvariant, [Runtime::InteropServices::Out] System::Object ^ % value);
protected static bool Convert (string text, System.Web.UI.WebControls.ValidationDataType type, bool cultureInvariant, out object value);
static member Convert : string * System.Web.UI.WebControls.ValidationDataType * bool * obj -> bool
Protected Shared Function Convert (text As String, type As ValidationDataType, cultureInvariant As Boolean, ByRef value As Object) As Boolean

Parameters

text
String

The text to convert.

type
ValidationDataType

One of the ValidationDataType values.

cultureInvariant
Boolean

true to convert values to a culture-neutral format; otherwise, false.

value
Object

When this method returns, contains an object with the conversion result. This parameter is passed uninitialized.

Returns

true if the conversion is successful; otherwise, false.

Remarks

The Convert(String, ValidationDataType, Boolean, Object) method is used to convert text into an object of the specified data type. Although the method returns true or false to indicate whether the conversion was successful, the converted value is stored in the value out parameter.

Note

If the conversion is unsuccessful, the value parameter is set to null.

To indicate that values should be converted using a culture-neutral format, pass in true for the cultureInvariant parameter; otherwise, values are converted using the format used by the current culture. When converting a value using the format used by the current culture, consider using the BaseCompareValidator.Convert(String, ValidationDataType, Object) overloaded version of this method.

See also

Applies to