Прочетете на английски Редактиране

Споделяне чрез


ValidatorCollection.CopyTo(Array, Int32) Method

Definition

Copies the validator collection to the specified array, beginning at the specified location.

C#
public void CopyTo(Array array, int index);

Parameters

array
Array

The collection to which the validation server control is added.

index
Int32

The index where the validation server control is copied.

Implements

Examples

The following code example demonstrates using the CopyTo method.

C#
// 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;

Applies to

Продукт Версии
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also