This documentation is archived and is not being maintained.

HttpStaticObjectsCollection.CopyTo Method

Copies members of an HttpStaticObjectsCollection into an array.

[Visual Basic]
Public Overridable Sub CopyTo( _
   ByVal array As Array, _
   ByVal index As Integer _
) Implements ICollection.CopyTo
[C#]
public virtual void CopyTo(
 Array array,
 int index
);
[C++]
public: virtual void CopyTo(
 Array* array,
 int index
);
[JScript]
public function CopyTo(
   array : Array,
 index : int
);

Parameters

array
The array to copy the HttpStaticObjectsCollection into.
index
The member of the collection where copying starts.

Implements

ICollection.CopyTo

Example

The following example creates a new Object array of the required size and copies an existing StaticObjects collection into it.

[Visual Basic] 
' Find the number of members in the StaticObjects collection.
Dim ObjCount As Integer = Application.StaticObjects.Count
' Create an array of the same size.
Dim MyObjArray As Array = Array.CreateInstance(Type.GetType("System.Object"), ObjCount)
' Copy the entire collection into the array.
Application.StaticObjects.CopyTo(MyObjArray, 0)


[C#] 
// Find the number of members in the StaticObjects collection.
int ObjCount = Application.StaticObjects.Count;
// Create an array of the same size.
Array MyObjArray = Array.CreateInstance(Type.GetType("System.Object"), ObjCount);
// Copy the entire collection into the array.
Application.StaticObjects.CopyTo(MyObjArray, 0);


[C++] 
// Find the number of members in the StaticObjects collection.
int ObjCount = Application->StaticObjects->Count;
// Create an array of the same size.
Array* MyObjArray = Array::CreateInstance(Type::GetType(S"System.Object"), ObjCount);
// Copy the entire collection into the array.
Application->StaticObjects->CopyTo(MyObjArray, 0);


[JScript] 
// Find the number of members in the StaticObjects collection.
var objCount : int = Application.StaticObjects.Count
// Create an array of the same size.
var myObjArray : System.Array = System.Array.CreateInstance(System.Object, objCount)
// Copy the entire collection into the array.
Application.StaticObjects.CopyTo(myObjArray, 0)

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

HttpStaticObjectsCollection Class | HttpStaticObjectsCollection Members | System.Web Namespace

Show: