語言

ServiceDescriptionCollection.IndexOf(ServiceDescription) 方法

定義

搜尋指定的 ServiceDescription 索引,並回傳集合中首次出現的零為基礎索引。

public:
 int IndexOf(System::Web::Services::Description::ServiceDescription ^ serviceDescription);
public int IndexOf(System.Web.Services.Description.ServiceDescription serviceDescription);
member this.IndexOf : System.Web.Services.Description.ServiceDescription -> int
Public Function IndexOf (serviceDescription As ServiceDescription) As Integer

參數

serviceDescription
ServiceDescription

在收藏中尋找的對象 ServiceDescription 。

傳回

指定服務描述的以零為基礎的索引,或若該元素未在集合中,則為 -1。

範例

// Get the index of 'ServiceDescription' object.
int myIndex = myCollection.IndexOf(myServiceDescription2);
// Remove 'ServiceDescription' object from the collection.
myCollection.Remove(myServiceDescription2);
Console.WriteLine("Element at index {0} is removed ", myIndex);
' Get the index of 'ServiceDescription' object.
Dim myIndex As Integer = myCollection.IndexOf(myServiceDescription2)
' Remove 'ServiceDescription' object from the collection.
myCollection.Remove(myServiceDescription2)
Console.WriteLine("Element at index {0} is removed ", myIndex.ToString())

適用於