次の方法で共有


PortCollection.Contains メソッド

指定した PortPortCollection のメンバかどうかを示す値を返します。

Public Function Contains( _
   ByVal port As Port _) As Boolean
[C#]
public bool Contains(Portport);
[C++]
public: bool Contains(Port* port);
[JScript]
public function Contains(
   port : Port) : Boolean;

パラメータ

  • port
    コレクション メンバシップを確認する対象の Port

戻り値

指定した PortPortCollection のメンバである場合は true 。それ以外の場合は false

使用例

 
myPortCollection = myService.Ports
Dim myNewPort As Port = myPortCollection(0)
myPortCollection.Remove(myNewPort)

' Display the number of ports.
Console.WriteLine(ControlChars.NewLine & _
   "Total number of ports before " & _
   "adding a new port : " & _
   myService.Ports.Count.ToString)

' Add a new port.
myPortCollection.Add(myNewPort)

' Display the number of ports after adding a port.
Console.WriteLine("Total number of ports after " & _
   "adding a new port : " & _
   myService.Ports.Count.ToString)


[C#] 

           myPortCollection = myService.Ports;
           Port myNewPort = myPortCollection[0];
           
           myPortCollection.Remove(myNewPort);

           // Display the number of ports.
           Console.WriteLine("\nTotal number of ports before"
              + " adding a new port : " +  myService.Ports.Count);

           // Add a new port.
           myPortCollection.Add(myNewPort);

           // Display the number of ports after adding a port.
           Console.WriteLine("Total number of ports after"
              + " adding a new port : " + myService.Ports.Count);


[C++] 

           myPortCollection = myService->Ports;
           Port* myNewPort = myPortCollection->Item[0];
           
           myPortCollection->Remove(myNewPort);

           // Display the number of ports.
           Console::WriteLine(S"\nTotal number of ports before adding a new port : {0}", __box(myService->Ports->Count));

           // Add a new port.
           myPortCollection->Add(myNewPort);

           // Display the number of ports after adding a port.
           Console::WriteLine(S"Total number of ports after adding a new port : {0}", __box(myService->Ports->Count));

[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 名前空間