MessageCollection.IndexOf(Message) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
搜尋指定的 Message,並傳回集合中第一個符合項目之以零起始的索引。
public:
int IndexOf(System::Web::Services::Description::Message ^ message);
public int IndexOf (System.Web.Services.Description.Message message);
member this.IndexOf : System.Web.Services.Description.Message -> int
Public Function IndexOf (message As Message) As Integer
參數
傳回
32 位元帶正負號的整數。
範例
下列範例示範 IndexOf
方法的用法。
// 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