ValidatorCollection.CopyTo(Array, Int32) 方法

定义

从指定位置开始,将验证程序集合复制到指定数组。

public:
 virtual void CopyTo(Array ^ array, int index);
public void CopyTo (Array array, int index);
abstract member CopyTo : Array * int -> unit
override this.CopyTo : Array * int -> unit
Public Sub CopyTo (array As Array, index As Integer)

参数

array
Array

要向其添加验证服务器控件的集合。

index
Int32

在该处复制验证服务器控件的索引。

实现

示例

下面的代码示例演示如何使用 CopyTo 方法。

// Get 'Validators' of the page to myCollection.
ValidatorCollection myCollection = Page.Validators ;
// Object Array.
Object[] myObjArray = new Object[5] { 0, 0, 0, 0, 0 };
// Copy the 'Collection' to 'Array'. 
myCollection.CopyTo(myObjArray,0); 
// Print the values in the Array.
string myStr = " ";         
for(int i = 0; i<myCollection.Count; i++)
{
   myStr += myObjArray[i].ToString();
   myStr += " ";
}
msgLabel.Text = myStr;
' Get 'Validators' of the page to myCollection.
Dim myCollection As ValidatorCollection = Page.Validators
Dim myObjArray() As Object = New Object(4){0, 0, 0, 0, 0}
' Copy the 'Collection' to 'Array'. 
myCollection.CopyTo(myObjArray, 0)
' Print the values in the Array.
Dim myStr As String = " "
Dim i As Integer
For i = 0 To myCollection.Count - 1
   myStr += myObjArray(i).ToString()
   myStr += " "
Next i
msgLabel.Text = myStr

适用于

另请参阅