MessagePartCollection.Item[] Property

Definition

Gets or sets the value of a MessagePart specified by the parameter passed in.

Overloads

Item[Int32]

Gets or sets the value of a MessagePart at the specified zero-based index.

Item[String]

Gets a MessagePart specified by its name.

Item[Int32]

Gets or sets the value of a MessagePart at the specified zero-based index.

C#
public System.Web.Services.Description.MessagePart this[int index] { get; set; }

Parameters

index
Int32

The zero-based index of the MessagePart whose value is modified or returned.

Property Value

A MessagePart.

Examples

The following example demonstrates the use of a zero-based index to iterate through the members of a MessagePartCollection.

C#
// Get the message part collection for each message.
for(int i =0; i < myMessageCollection.Count; ++i)
{
   Console.WriteLine("Message      : " + myMessageCollection[i].Name);

   // Get the message part collection.
   MessagePartCollection myMessagePartCollection =
      myMessageCollection[i].Parts;

   // Display the part collection.
   for(int k = 0; k < myMessagePartCollection.Count;k++)
   {
      Console.WriteLine("\t       Part Name     : " +
         myMessagePartCollection[k].Name);
      Console.WriteLine("\t       Message Name  : " +
         myMessagePartCollection[k].Message.Name);
   }
   Console.WriteLine("");
}

Applies to

.NET Framework 4.8.1 и друге верзије
Производ Верзије
.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)

Item[String]

Gets a MessagePart specified by its name.

C#
public System.Web.Services.Description.MessagePart this[string name] { get; }

Parameters

name
String

The name of the MessagePart returned.

Property Value

A MessagePart.

Examples

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 4.8.1 и друге верзије
Производ Верзије
.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)