編集

次の方法で共有


IntegerValidatorAttribute.ValidatorInstance Property

Definition

Gets an instance of the IntegerValidator 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

The ConfigurationValidatorBase validator instance.

Examples

The following example shows how to use the ValidatorInstance property.


            ConfigurationValidatorBase valBase;
            IntegerValidatorAttribute intValAttr;
            intValAttr = new IntegerValidatorAttribute();

            long badValue = 10;
            int goodValue = 10;

            try
            {
                valBase = intValAttr.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 intValAttr As IntegerValidatorAttribute
        intValAttr = New IntegerValidatorAttribute()

        Dim badValue As Long = 10
        Dim goodValue As Integer = 10

        Try
            valBase = intValAttr.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