MessageCollection.Contains(Message) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回一个值,该值指示指定的 Message 是否是 MessageCollection 的成员。
public:
bool Contains(System::Web::Services::Description::Message ^ message);
public bool Contains (System.Web.Services.Description.Message message);
member this.Contains : System.Web.Services.Description.Message -> bool
Public Function Contains (message As Message) As Boolean
参数
返回
如果 message
参数是 MessageCollection 的成员,则为 true
;否则为 false
。
示例
下面的示例演示 Contains
方法的用法。
// 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