MessagePartCollection.IndexOf メソッド
指定した MessagePart を検索し、コレクション内で最初に見つかった位置の 0 から始まるインデックス番号を返します。
Public Function IndexOf( _
ByVal messagePart As MessagePart _) As Integer
[C#]
public int IndexOf(MessagePartmessagePart);
[C++]
public: int IndexOf(MessagePart* messagePart);
[JScript]
public function IndexOf(
messagePart : MessagePart) : int;
パラメータ
- messagePart
コレクション内での検索対象となる MessagePart 。
戻り値
32 ビット符号付き整数。
使用例
[Visual Basic, C#, C++] IndexOf メソッドを使用して、指定した MessagePart がコレクションのメンバであるかどうかを確認する例を次に示します。
Console.WriteLine("Checking if message is AddHttpPostOut...")
Dim myMessage As Message = myServiceDescription.Messages("AddHttpPostOut")
If myMessageCollection.Contains(myMessage) Then
' Get the message part collection.
Dim myMessagePartCollection As MessagePartCollection = myMessage.Parts
' Get the part named Body.
Dim myMessagePart As MessagePart = myMessage.Parts("Body")
If myMessagePartCollection.Contains(myMessagePart) Then
' Get the index of the part named Body.
Console.WriteLine("Index of Body in MessagePart collection = " & _
myMessagePartCollection.IndexOf(myMessagePart).ToString)
Console.WriteLine("Deleting Body from MessagePart Collection...")
myMessagePartCollection.Remove(myMessagePart)
If myMessagePartCollection.IndexOf(myMessagePart) = -1 Then
Console.WriteLine("MessagePart Body successfully deleted " & _
"from the message AddHttpPostOut.")
End If
End If
End If
[C#]
Console.WriteLine("Checking if message is AddHttpPostOut...");
Message myMessage = myServiceDescription.Messages["AddHttpPostOut"];
if (myMessageCollection.Contains(myMessage))
{
// Get the message part collection.
MessagePartCollection myMessagePartCollection = myMessage.Parts;
// Get the part named Body.
MessagePart myMessagePart = myMessage.Parts["Body"];
if (myMessagePartCollection.Contains(myMessagePart))
{
// Get the index of the part named Body.
Console.WriteLine("Index of Body in MessagePart collection = " +
myMessagePartCollection.IndexOf(myMessagePart));
Console.WriteLine("Deleting Body from MessagePart collection...");
myMessagePartCollection.Remove(myMessagePart);
if(myMessagePartCollection.IndexOf(myMessagePart)== -1)
{
Console.WriteLine("MessagePart Body successfully deleted " +
"from the message AddHttpPostOut.");
}
}
}
[C++]
Console::WriteLine(S"Checking if message is AddHttpPostOut...");
Message* myMessage = myServiceDescription->Messages->Item[S"AddHttpPostOut"];
if (myMessageCollection->Contains(myMessage))
{
// Get the mssage part collection.
MessagePartCollection* myMessagePartCollection = myMessage->Parts;
// Get the part named Body.
MessagePart* myMessagePart = myMessage->Parts->Item[S"Body"];
if (myMessagePartCollection->Contains(myMessagePart))
{
// Get the part named Body.
Console::WriteLine(S"Index of Body in MessagePart collection = {0}",
__box( myMessagePartCollection->IndexOf(myMessagePart)));
Console::WriteLine(S"Deleting Body from MessagePart collection...");
myMessagePartCollection->Remove(myMessagePart);
if (myMessagePartCollection->IndexOf(myMessagePart)== -1)
Console::WriteLine(S"MessagePart Body successfully deleted "\
S"from the message AddHttpPostOut.");
}
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
MessagePartCollection クラス | MessagePartCollection メンバ | System.Web.Services.Description 名前空間