StringValidatorAttribute.ValidatorInstance Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets an instance of the StringValidator class.
public:
virtual property System::Configuration::ConfigurationValidatorBase ^ ValidatorInstance { System::Configuration::ConfigurationValidatorBase ^ get(); };
public override System.Configuration.ConfigurationValidatorBase ValidatorInstance { get; }
member this.ValidatorInstance : System.Configuration.ConfigurationValidatorBase
Public Overrides ReadOnly Property ValidatorInstance As ConfigurationValidatorBase
Property Value
A current StringValidator settings in a ConfigurationValidatorBase validator instance.
Examples
The following example shows how to use the ValidatorInstance property.
ConfigurationValidatorBase valBase;
StringValidatorAttribute strValAttr =
new StringValidatorAttribute();
long badValue = 10;
string goodValue = "10";
try
{
valBase = strValAttr.ValidatorInstance;
valBase.Validate(goodValue);
// valBase.Validate(badValue);
}
catch (ArgumentException e)
{
// Display error message.
string msg = e.ToString();
#if DEBUG
Console.WriteLine(msg);
#endif
}
Dim valBase As ConfigurationValidatorBase
Dim strValAttr As New StringValidatorAttribute()
Dim badValue As Long = 10
Dim goodValue As String = "10"
Try
valBase = strValAttr.ValidatorInstance
valBase.Validate(goodValue)
' valBase.Validate(badValue);
Catch e As ArgumentException
' Display error message.
Dim msg As String = e.ToString()
#If DEBUG Then
Console.WriteLine(msg)
#End If
End Try '
Remarks
You use the ValidatorInstance property to perform string validation by calling its Validate method.
Applies to
See also
Samarbeid med oss på GitHub
Du finner kilden for dette innholdet på GitHub. Der du også kan opprette og se gjennom problemer og pull-forespørsler. Hvis du vil ha mer informasjon, kan du se vår bidragsyterveiledning.