StringValidator.Validate(Object) 方法
定义
确定对象的值是否有效。Determines whether the value of an object is valid.
public:
override void Validate(System::Object ^ value);
public override void Validate (object value);
override this.Validate : obj -> unit
Public Overrides Sub Validate (value As Object)
参数
- value
- Object
对象值。The object value.
例外
value 小于构造函数中定义的 minValue 或大于构造函数中定义的 maxValue。value is less than minValue or greater than maxValue as defined in the constructor.
- 或 --or-
value 包含无效字符。value contains invalid characters.
示例
下面的示例演示如何使用 Validate 方法。The following example demonstrates how to use the Validate method. 此代码示例是为类提供的更大示例的一部分 StringValidator 。This code example is part of a larger example provided for the StringValidator class.
// Attempt validation.
myStrValidator.Validate(testVal);
' Attempt validation.
myStrValidator.Validate(testVal)
注解
StringValidator类包含验证字符串对象所需的条件。The StringValidator class contains the criteria necessary to validate a string object. 条件是在创建类的实例时建立的 StringValidator 。The criteria are established when an instance of the StringValidator class is created. 要验证的对象作为方法的参数传递 Validate 。The object to validate is passed as a parameter of the Validate method.