Compartir a través de


MessageCollection.Item[] Propiedad

Definición

Obtiene o establece la instancia de Message especificada por el parámetro que se ha pasado.

Sobrecargas

Item[Int32]

Obtiene o establece el valor de Message en el índice de base cero especificado.

Item[String]

Obtiene un objeto Message especificado por su nombre.

Item[Int32]

Obtiene o establece el valor de Message en el índice de base cero especificado.

public:
 property System::Web::Services::Description::Message ^ default[int] { System::Web::Services::Description::Message ^ get(int index); void set(int index, System::Web::Services::Description::Message ^ value); };
public System.Web.Services.Description.Message this[int index] { get; set; }
member this.Item(int) : System.Web.Services.Description.Message with get, set
Default Public Property Item(index As Integer) As Message

Parámetros

index
Int32

El índice de base cero del objeto Message cuyo valor se ha modificado o devuelto.

Valor de propiedad

Message

Objeto Message.

Ejemplos

En el ejemplo siguiente se muestra el uso de un índice de base cero para recorrer en iteración los miembros de .MessageCollection

// Get Message Collection.
MessageCollection^ myMessageCollection = myServiceDescription->Messages;
Console::WriteLine( "Total Messages in the document = {0}", myServiceDescription->Messages->Count );
Console::WriteLine( "" );
Console::WriteLine( "Enumerating Messages..." );
Console::WriteLine( "" );

// Print messages to console.
for ( int i = 0; i < myMessageCollection->Count; ++i )
   Console::WriteLine( "Message Name : {0}", myMessageCollection[ i ]->Name );
// Get Message Collection.
MessageCollection myMessageCollection = myServiceDescription.Messages;
Console.WriteLine("Total Messages in the document = " + myServiceDescription.Messages.Count);
Console.WriteLine("");
Console.WriteLine("Enumerating Messages...");
Console.WriteLine("");
// Print messages to console.
for(int i =0; i < myMessageCollection.Count; ++i)
{
   Console.WriteLine("Message Name : " + myMessageCollection[i].Name);
}
' Get Message Collection.
Dim myMessageCollection As MessageCollection = myServiceDescription.Messages
Console.WriteLine("Total Messages in the document = " + _
                        myServiceDescription.Messages.Count.ToString)
Console.WriteLine("")
Console.WriteLine("Enumerating Messages...")
Console.WriteLine("")
' Print messages to console.
Dim i As Integer
For i = 0 To myMessageCollection.Count - 1
   Console.WriteLine("Message Name : " + myMessageCollection(i).Name)
Next

Se aplica a

Item[String]

Obtiene un objeto Message especificado por su nombre.

public:
 property System::Web::Services::Description::Message ^ default[System::String ^] { System::Web::Services::Description::Message ^ get(System::String ^ name); };
public System.Web.Services.Description.Message this[string name] { get; }
member this.Item(string) : System.Web.Services.Description.Message
Default Public ReadOnly Property Item(name As String) As Message

Parámetros

name
String

Nombre del objeto Message devuelto.

Valor de propiedad

Message

Objeto Message.

Ejemplos

En el ejemplo siguiente se muestra el uso de una cadena para recuperar un Message.

// Get Message by Name = S"AddSoapIn".
Message^ myMessage = myServiceDescription->Messages[ "AddSoapIn" ];
Console::WriteLine( "" );
Console::WriteLine( "Getting Message = 'AddSoapIn' {by Name}" );
if ( myMessageCollection->Contains( myMessage ) )
{
   Console::WriteLine( "" );

   // Get Message Name = S"AddSoapIn" Index.
   Console::WriteLine( "Message 'AddSoapIn' was found in Message Collection." );
   Console::WriteLine( "Index of 'AddSoapIn' in Message Collection = {0}", myMessageCollection->IndexOf( myMessage ) );
   Console::WriteLine( "Deleting Message from Message Collection..." );
   myMessageCollection->Remove( myMessage );
   if ( myMessageCollection->IndexOf( myMessage ) == -1 )
         Console::WriteLine( "Message 'AddSoapIn' was successfully removed from Message Collection." );
}
// Get Message by Name = "AddSoapIn".
Message myMessage = myServiceDescription.Messages["AddSoapIn"];
Console.WriteLine("");
Console.WriteLine("Getting Message = 'AddSoapIn' {by Name}");
if (myMessageCollection.Contains(myMessage))
{
   Console.WriteLine("");
   // Get Message Name = "AddSoapIn" Index.
   Console.WriteLine("Message 'AddSoapIn' was found in Message Collection.");
   Console.WriteLine("Index of 'AddSoapIn' in Message Collection = " + myMessageCollection.IndexOf(myMessage));
   Console.WriteLine("Deleting Message from Message Collection...");
   myMessageCollection.Remove(myMessage);
   if(myMessageCollection.IndexOf(myMessage) == -1)
   {
      Console.WriteLine("Message 'AddSoapIn' was successfully removed from Message Collection.");
   }
}
' Get Message by Name = "AddSoapIn".
Dim myMessage As Message = myServiceDescription.Messages("AddSoapIn")
Console.WriteLine("")
Console.WriteLine("Getting Message = 'AddSoapIn' {by Name}")
If myMessageCollection.Contains(myMessage) Then
   Console.WriteLine("")
   ' Get Message Name = "AddSoapIn" Index.
   Console.WriteLine("Message 'AddSoapIn' was found in Message Collection.")
   Console.WriteLine("Index of 'AddSoapIn' in Message Collection = " + _
                     myMessageCollection.IndexOf(myMessage).ToString)
   Console.WriteLine("Deleting Message from Message Collection...")
   myMessageCollection.Remove(myMessage)
   If myMessageCollection.IndexOf(myMessage) = -1 Then
      Console.WriteLine("Message 'AddSoapIn' was successfully " + _
                        " removed from Message Collection.")
   End If
End If

Se aplica a