MessageCollection.Item[] Propriedade
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Obtém ou define a instância Message especificada pelo parâmetro no qual ela foi passada.
Sobrecargas
Item[Int32] |
Obtém ou define o valor de um Message no índice de base zero especificado. |
Item[String] |
Obtém um especificado Message por seu nome. |
Item[Int32]
Obtém ou define o valor de um Message no índice de base zero 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
Valor da propriedade
Um Message
.
Exemplos
O exemplo a seguir demonstra o uso de um índice baseado em zero para iterar por meio dos membros de um 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
Aplica-se a
Item[String]
Obtém um especificado Message por seu nome.
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
Valor da propriedade
Um Message
.
Exemplos
O exemplo a seguir demonstra o uso de uma cadeia de caracteres para recuperar um 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