ValidateCount 属性声明

ValidateCount 属性指定 cmdlet 参数允许的最小和最大参数数量。

语法

[ValidateCount(int minLength, int maxlength)]

参数

MinLength需要 () 。 指定参数的最小数目。

MaxLength需要 () 。 指定参数的最大数目。

备注

  • 有关如何声明此属性的详细信息,请参阅 如何验证参数计数
  • 如果未调用此属性,则对应的 cmdlet 参数可以有任意数量的参数。
  • Windows PowerShell 运行时在以下条件下引发错误:
    • MinLengthMaxLength 特性参数的类型不是system.object
    • Attribute 参数的值 MaxLength 小于 MinLength attribute 参数的值。
  • ValidateCount 特性是由 ValidateCountAttribute 类定义的。

另请参阅

System.web. ValidateCountAttribute

如何验证参数计数

编写 Windows PowerShell Cmdlet