MessagePartCollection.CopyTo(MessagePart[], Int32) Method

Definition

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

C#
public void CopyTo(System.Web.Services.Description.MessagePart[] array, int index);

Parameters

array
MessagePart[]

An array of type MessagePart serving as the destination of the copy action.

index
Int32

The zero-based index at which to start placing the copied collection.

Examples

The following example demonstrates a use of the CopyTo method.

C#
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("");
}

Applies to

Производ Верзије
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)