ValidatorCollection.CopyTo Method (Array, Int32)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

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

Namespace:   System.Web.UI
Assembly:  System.Web (in System.Web.dll)

public void CopyTo(
	Array array,
	int index


Type: System.Array

The collection to which the validation server control is added.

Type: System.Int32

The index where the validation server control is copied.

The following code example demonstrates using the CopyTo method.

// 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'. 
// Print the values in the Array.
string myStr = " ";         
for(int i = 0; i<myCollection.Count; i++)
   myStr += myObjArray[i].ToString();
   myStr += " ";
msgLabel.Text = myStr;

.NET Framework
Available since 1.1
Return to top