PositiveTimeSpanValidator.CanValidate(Type) 方法     
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
确定是否可验证该对象类型。
public:
 override bool CanValidate(Type ^ type);
	public override bool CanValidate (Type type);
	override this.CanValidate : Type -> bool
	Public Overrides Function CanValidate (type As Type) As Boolean
	参数
- type
 - Type
 
对象类型。
返回
如果 type 参数与 TimeSpan 对象匹配,则为 true;否则为 false。
示例
下面的代码示例演示如何使用 CanValidate 方法。 此代码示例是为 PositiveTimeSpanValidator 类提供的一个更大示例的一部分。
// Determine if the Validator can validate
// the type it contains.
valBase = customValAttr.ValidatorInstance;
if (valBase.CanValidate(resultTimeSpan.GetType()))
{
    // Validate the TimeSpan using a
    // custom PositiveTimeSpanValidator.
    valBase.Validate(resultTimeSpan);
}
' Determine if the Validator can validate
' the type it contains.
valBase = customValAttr.ValidatorInstance
If valBase.CanValidate(resultTimeSpan.GetType()) Then
    ' Validate the TimeSpan using a
    ' custom PositiveTimeSpanValidator.
    valBase.Validate(resultTimeSpan)
End If