ValidatorCollection.CopyTo Method (Array, Int32)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com 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
)

Parameters

array
Type: System.Array

The collection to which the validation server control is added.

index
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'. 
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;

.NET Framework
Available since 1.1
Return to top
Show: