指定した Port を検索し、コレクション内で最初に見つかった位置の 0 から始まるインデックス番号を返します。
Public Function IndexOf( _
ByVal port As Port _) As Integer
[C#]
public int IndexOf(Portport);
[C++]
public: int IndexOf(Port* port);
[JScript]
public function IndexOf(
port : Port) : int;
パラメータ
- port
コレクション内での検索対象となる Port 。
戻り値
32 ビット符号付き整数。
使用例
myPortCollection = myService.Ports
' Create an array of Port objects.
Console.WriteLine(ControlChars.NewLine & "Port collection :")
Dim myPortArray(myService.Ports.Count) As Port
myPortCollection.CopyTo(myPortArray, 0)
Dim i1 As Integer
For i1 = 0 to myService.Ports.Count -1
Console.WriteLine("Port[" & i1.ToString + "] : " & _
myPortArray(i1).Name)
Next
Dim myIndexPort As Port = myPortCollection(0)
Console.WriteLine(ControlChars.NewLine + ControlChars.NewLine + _
"The index of port '" + myIndexPort.Name + "' is : " + _
myPortCollection.IndexOf(myIndexPort).ToString)
[C#]
myPortCollection = myService.Ports;
// Create an array of Port objects.
Console.WriteLine("\nPort collection :");
Port[] myPortArray = new Port[myService.Ports.Count];
myPortCollection.CopyTo(myPortArray, 0);
for(int i1=0 ; i1 < myService.Ports.Count ; ++i1)
{
Console.WriteLine("Port[" + i1+ "] : " + myPortArray[i1].Name);
}
Port myIndexPort = myPortCollection[0];
Console.WriteLine("\n\nThe index of port '"
+ myIndexPort.Name + "' is : "
+ myPortCollection.IndexOf(myIndexPort));
[C++]
myPortCollection = myService->Ports;
// Create an array of Port objects.
Console::WriteLine(S"\nPort collection :");
Port* myPortArray[] = new Port*[myService->Ports->Count];
myPortCollection->CopyTo(myPortArray, 0);
for(int i1=0 ; i1 < myService->Ports->Count ; ++i1)
{
Console::WriteLine(S"Port[{0}] : {1}", __box(i1), myPortArray[i1]->Name);
}
Port* myIndexPort = myPortCollection->Item[0];
Console::WriteLine(S"\n\nThe index of port '{0}' is : {1}",
myIndexPort->Name, __box(myPortCollection->IndexOf(myIndexPort)));
[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 ファミリ
参照
PortCollection クラス | PortCollection メンバ | System.Web.Services.Description 名前空間