StringValidator 构造函数
定义
初始化 StringValidator 类的新实例。Initializes a new instance of the StringValidator class.
重载
| StringValidator(Int32) |
使用所提供的参数初始化 StringValidator 类的新实例。Initializes a new instance of the StringValidator class, based on a supplied parameter. |
| StringValidator(Int32, Int32) |
基于所提供的参数初始化 StringValidator 类的新实例。Initializes a new instance of the StringValidator class, based on supplied parameters. |
| StringValidator(Int32, Int32, String) |
基于所提供的参数初始化 StringValidator 类的新实例。Initializes a new instance of the StringValidator class, based on supplied parameters. |
StringValidator(Int32)
使用所提供的参数初始化 StringValidator 类的新实例。Initializes a new instance of the StringValidator class, based on a supplied parameter.
public:
StringValidator(int minLength);
public StringValidator (int minLength);
new System.Configuration.StringValidator : int -> System.Configuration.StringValidator
Public Sub New (minLength As Integer)
参数
- minLength
- Int32
一个整数,指定字符串值的最小长度。An integer that specifies the minimum length of the string value.
注解
StringValidator构造函数验证所验证的字符串可接受的最小长度。The StringValidator constructor verifies the minimum acceptable length of the string being validated.
适用于
StringValidator(Int32, Int32)
基于所提供的参数初始化 StringValidator 类的新实例。Initializes a new instance of the StringValidator class, based on supplied parameters.
public:
StringValidator(int minLength, int maxLength);
public StringValidator (int minLength, int maxLength);
new System.Configuration.StringValidator : int * int -> System.Configuration.StringValidator
Public Sub New (minLength As Integer, maxLength As Integer)
参数
- minLength
- Int32
一个整数,指定字符串值的最小长度。An integer that specifies the minimum length of the string value.
- maxLength
- Int32
一个整数,指定字符串值的最大长度。An integer that specifies the maximum length of the string value.
注解
此 StringValidator 构造函数可确保所验证的字符串符合最小和最大长度。This StringValidator constructor ensures that the string being verified adheres to both a minimum and a maximum length.
适用于
StringValidator(Int32, Int32, String)
基于所提供的参数初始化 StringValidator 类的新实例。Initializes a new instance of the StringValidator class, based on supplied parameters.
public:
StringValidator(int minLength, int maxLength, System::String ^ invalidCharacters);
public StringValidator (int minLength, int maxLength, string invalidCharacters);
new System.Configuration.StringValidator : int * int * string -> System.Configuration.StringValidator
Public Sub New (minLength As Integer, maxLength As Integer, invalidCharacters As String)
参数
- minLength
- Int32
一个整数,指定字符串值的最小长度。An integer that specifies the minimum length of the string value.
- maxLength
- Int32
一个整数,指定字符串值的最大长度。An integer that specifies the maximum length of the string value.
- invalidCharacters
- String
一个表示无效字符的字符串。A string that represents invalid characters.
示例
下面的示例演示如何使用此 StringValidator 构造函数。The following example demonstrates how to use this StringValidator constructor. 此代码示例是为类提供的更大示例的一部分 StringValidator 。This code example is part of a larger example provided for the StringValidator class.
// Create string and validator.
string testVal = "filename";
StringValidator myStrValidator = new StringValidator(1,8,"$%^");
' Create string and validator.
Dim testVal As String = "filename"
Dim myStrValidator As StringValidator = New StringValidator(1, 8, "$%^")
注解
此 StringValidator 构造函数可确保所验证的字符串符合最小长度和最大长度,并确保在字符串中排除特定字符。This StringValidator constructor ensures that the string being validated adheres to both a minimum and a maximum length, and also ensures that specific characters are excluded in the string.