共用方式為


MessageCollection.Item[] 屬性

定義

取得或設定傳入參數所指定的 Message 執行個體。

多載

Item[Int32]

取得或設定 Message 的值,於指定的以零起始的索引位置。

Item[String]

取得由其名稱所指定的 Message

Item[Int32]

取得或設定 Message 的值,於指定的以零起始的索引位置。

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

參數

index
Int32

Message (其值已修改或傳回) 的以零起始的索引。

屬性值

Message

Message

範例

下列範例示範如何使用以零起始的索引逐一查看 的成員 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

適用於

Item[String]

取得由其名稱所指定的 Message

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

參數

name
String

傳回的 Message 的名稱。

屬性值

Message

Message

範例

下列範例示範如何使用字串來擷取 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

適用於