RegexStringValidator.CanValidate(Type) RegexStringValidator.CanValidate(Type) RegexStringValidator.CanValidate(Type) Method

定义

确定是否可以验证该对象的类型。Determines whether the type of the object can be validated.

public:
 override bool CanValidate(Type ^ type);
public override bool CanValidate (Type type);
override this.CanValidate : Type -> bool

参数

type
Type Type Type

对象的类型。The type of object.

返回

如果 type 参数与字符串匹配,则为 true;否则为 falsetrue if the type parameter matches a string; otherwise, false.

示例

下面的示例演示如何使用 CanValidate 方法。The following example demonstrates how to use the CanValidate method. 此代码示例是为提供一个更大示例的一部分RegexStringValidator类。This code example is part of a larger example that is provided for the RegexStringValidator class.

// Determine if the object to validate can be validated.
Console.WriteLine("CanValidate: {0}",
  myRegexValidator.CanValidate(testString.GetType()));
' Determine if the object to validate can be validated.
Console.WriteLine("CanValidate: {0}", _
  myRegexValidator.CanValidate(testString.GetType()))

注解

如果验证失败,将引发异常。An exception is thrown if the validation fails.

适用于