This documentation is archived and is not being maintained.

MimePartCollection.CopyTo Method

Copies the entire MimePartCollection to a compatible one-dimensional array of type MimePart, starting at the specified zero-based index of the target array.

[Visual Basic]
Public Sub CopyTo( _
   ByVal array() As MimePart, _
   ByVal index As Integer _
)
[C#]
public void CopyTo(
 MimePart[] array,
 int index
);
[C++]
public: void CopyTo(
 MimePart* array[],
 int index
);
[JScript]
public function CopyTo(
   array : MimePart[],
 index : int
);

Parameters

array
An array of type MimePart serving as the destination for the copy action.
index
The zero-based index at which to start placing the copied collection.

Example

[Visual Basic, C#, C++] The following example demonstrates a typical use of the CopyTo method.

[Visual Basic] 
Dim myArray(myMimePartCollection.Count-1) As MimePart
' Copy the mimepartcollection to an array.
myMimePartCollection.CopyTo(myArray, 0)
Console.WriteLine("Displaying the array copied from mimepartcollection")
Dim j As Integer
For j = 0 To myMimePartCollection.Count - 1
   Console.WriteLine("Mimepart object at position : " + j.ToString())
   For i = 0 To (myArray(j).Extensions.Count) - 1
      Dim myMimeXmlBinding3 As MimeXmlBinding = CType(myArray(j).Extensions(i), _
                                                                     MimeXmlBinding)
      Console.WriteLine("Part: " + myMimeXmlBinding3.Part)
   Next i
Next j

[C#] 
MimePart[] myArray = new MimePart[myMimePartCollection.Count];
// Copy the mimepartcollection to an array.
myMimePartCollection.CopyTo(myArray,0);
Console.WriteLine("Displaying the array copied from mimepartcollection");
for(int j=0;j<myMimePartCollection.Count;j++)
{
   Console.WriteLine("Mimepart object at position : " + j);
   for(int i=0;i<myArray[j].Extensions.Count;i++)
   {
      MimeXmlBinding myMimeXmlBinding3 = (MimeXmlBinding)myArray[j].Extensions[i];
      Console.WriteLine("Part: "+(myMimeXmlBinding3.Part));
   }
}

[C++] 
MimePart* myArray[] = new MimePart*[myMimePartCollection->Count];
// Copy the mimepartcollection to an array.
myMimePartCollection->CopyTo(myArray, 0);
Console::WriteLine(S"Displaying the array copied from mimepartcollection");
for (int j=0;j<myMimePartCollection->Count;j++)
{
   Console::WriteLine(S"Mimepart object at position : {0}",__box(j));
   for (int i=0;i<myArray[j]->Extensions->Count;i++)
   {
      MimeXmlBinding * myMimeXmlBinding3 = 
         dynamic_cast<MimeXmlBinding*>(myArray[j]->Extensions->Item[i]);
      Console::WriteLine(S"Part: {0}", (myMimeXmlBinding3->Part));
   }
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

MimePartCollection Class | MimePartCollection Members | System.Web.Services.Description Namespace

Show: