Compartir a través de


MessagePartCollection.CopyTo(MessagePart[], Int32) Método

Definición

Copia todo el objeto MessagePartCollection en una matriz unidimensional compatible de tipo MessagePart, a partir del índice de base cero especificado de la matriz de destino.

public:
 void CopyTo(cli::array <System::Web::Services::Description::MessagePart ^> ^ array, int index);
public void CopyTo (System.Web.Services.Description.MessagePart[] array, int index);
member this.CopyTo : System.Web.Services.Description.MessagePart[] * int -> unit
Public Sub CopyTo (array As MessagePart(), index As Integer)

Parámetros

array
MessagePart[]

Matriz de tipo MessagePart que actúa como destino de la operación de copia.

index
Int32

Índice de base cero en el que se comienza a insertar la colección copiada.

Ejemplos

En el ejemplo siguiente se muestra un uso del CopyTo método .

Message^ myLocalMessage = myServiceDescription->Messages[ "AddHttpPostOut" ];
if ( myMessageCollection->Contains( myLocalMessage ) )
{
   Console::WriteLine( "Message      : {0}", myLocalMessage->Name );

   // Get the message part collection.
   MessagePartCollection^ myMessagePartCollection = myLocalMessage->Parts;
   array<MessagePart^>^myMessagePart = gcnew array<MessagePart^>(myMessagePartCollection->Count);
   
   // Copy the MessagePartCollection to an array.
   myMessagePartCollection->CopyTo( myMessagePart, 0 );
   for ( int k = 0; k < myMessagePart->Length; k++ )
      Console::WriteLine( "\t       Part Name : {0}", myMessagePartCollection[ k ]->Name );
   Console::WriteLine( "" );
}
Message myLocalMessage = myServiceDescription.Messages["AddHttpPostOut"];
if (myMessageCollection.Contains(myLocalMessage))
{
   Console.WriteLine("Message      : " + myLocalMessage.Name);

   // Get the message part collection.
   MessagePartCollection myMessagePartCollection = myLocalMessage.Parts;
   MessagePart[] myMessagePart  =
      new MessagePart[myMessagePartCollection.Count];

   // Copy the MessagePartCollection to an array.
   myMessagePartCollection.CopyTo(myMessagePart,0);
   for(int k = 0; k < myMessagePart.Length; k++)
   {
      Console.WriteLine("\t       Part Name : " +
         myMessagePartCollection[k].Name);
   }
   Console.WriteLine("");
}
Dim myLocalMessage As Message = _
   myServiceDescription.Messages("AddHttpPostOut")
If myMessageCollection.Contains(myLocalMessage) Then
   Console.WriteLine("Message      : " & myLocalMessage.Name)

   ' Get the message part collection.
   Dim myMessagePartCollection As MessagePartCollection = _
      myLocalMessage.Parts
   Dim myMessagePart(myMessagePartCollection.Count) As MessagePart

   ' Copy the MessagePartCollection to an array.
   myMessagePartCollection.CopyTo(myMessagePart, 0)
   Dim k As Integer
   For k = 0 To myMessagePart.Length - 2
      Console.WriteLine(ControlChars.Tab & "       Part Name : " & _
         myMessagePartCollection(k).Name)
   Next k
   Console.WriteLine("")
End If

Se aplica a