MessageCollection.Item[] Propriété

Définition

Obtient ou définit l'instance Message spécifiée par le paramètre passé.

Surcharges

Item[Int32]

Obtient ou définit la valeur d'une Message à l'index de base zéro spécifié.

Item[String]

Obtient un Message spécifié par son nom.

Item[Int32]

Obtient ou définit la valeur d'une Message à l'index de base zéro spécifié.

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

Paramètres

index
Int32

Index de base zéro de Message dont la valeur est modifiée ou retournée.

Valeur de propriété

Message

Message

Exemples

L’exemple suivant illustre l’utilisation d’un index de base zéro pour itérer par le biais des membres d’un 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

S’applique à

Item[String]

Obtient un Message spécifié par son nom.

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

Paramètres

name
String

Nom de la classe Message retournée.

Valeur de propriété

Message

Message

Exemples

L’exemple suivant illustre l’utilisation d’une chaîne pour récupérer 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

S’applique à