PortCollection.IndexOf Method (Port)

 

Searches for the specified Port and returns the zero-based index of the first occurrence within the collection.

Namespace:   System.Web.Services.Description
Assembly:  System.Web.Services (in System.Web.Services.dll)

Public Function IndexOf (
	port As Port
) As Integer

Parameters

port
Type: System.Web.Services.Description.Port

The Port for which to search in the collection.

Return Value

Type: System.Int32

A 32-bit signed integer.

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)

.NET Framework
Available since 1.1
Return to top
Show: