Message.FindPartByName(String) 方法

定义

搜索由 MessagePartCollection 属性返回的 Parts,并返回已命名的 MessagePart

public:
 System::Web::Services::Description::MessagePart ^ FindPartByName(System::String ^ partName);
public System.Web.Services.Description.MessagePart FindPartByName (string partName);
member this.FindPartByName : string -> System.Web.Services.Description.MessagePart
Public Function FindPartByName (partName As String) As MessagePart

参数

partName
String

命名要返回的 MessagePart 的字符串。

返回

MessagePart

MessagePart

例外

集合中不存在具有指定名称的 MessagePart

示例

下面的示例演示 FindPartByName 方法的用法。

// Get another message from ServiceDescription.
Message^ myMessage2 = myServiceDescription->Messages[ "DivideHttpGetOut" ];
MessagePart^ myMessagePart = myMessage2->FindPartByName( "Body" );
Console::WriteLine( "Results of FindPartByName operation:" );
Console::WriteLine( "Part Name: {0}", myMessagePart->Name );
Console::WriteLine( "Part Element: {0}", myMessagePart->Element );
// Get another message from ServiceDescription.
Message myMessage2 = myServiceDescription.Messages["DivideHttpGetOut"];
MessagePart myMessagePart=myMessage2.FindPartByName("Body");
Console.WriteLine("Results of FindPartByName operation:");
Console.WriteLine("Part Name: " +myMessagePart.Name);
Console.WriteLine("Part Element: " +myMessagePart.Element);
' Get another message from ServiceDescription.
Dim myMessage2 As Message = myServiceDescription.Messages("DivideHttpGetOut")
Dim myMessagePart As MessagePart = myMessage2.FindPartByName("Body")
Console.WriteLine("Results of FindPartByName operation:")
Console.WriteLine("Part Name: " + myMessagePart.Name)
Console.WriteLine("Part Element: " + myMessagePart.Element.ToString())

适用于