CodeNamespaceCollection.IndexOf(CodeNamespace) 方法

定義

如果指定物件存在於集合中,則取得該物件CodeNamespace的索引CodeNamespaceCollection

public:
 int IndexOf(System::CodeDom::CodeNamespace ^ value);
public int IndexOf(System.CodeDom.CodeNamespace value);
member this.IndexOf : System.CodeDom.CodeNamespace -> int
Public Function IndexOf (value As CodeNamespace) As Integer

參數

value
CodeNamespace

CodeNamespace要找到。

傳回

若在集合中找到指定 CodeNamespace的索引,則為 ;否則為 -1。

範例

以下範例搜尋特定 CodeNamespace 值的存在,並使用此 IndexOf 方法取得該特定值所在的索引值。

// Tests for the presence of a CodeNamespace in the collection,
// and retrieves its index if it is found.
CodeNamespace testNamespace = new CodeNamespace("TestNamespace");
int itemIndex = -1;
if( collection.Contains( testNamespace ) )
    itemIndex = collection.IndexOf( testNamespace );
' Tests for the presence of a CodeNamespace in the collection,
' and retrieves its index if it is found.
Dim testNamespace As New CodeNamespace("TestNamespace")
Dim itemIndex As Integer = -1
If collection.Contains(testNamespace) Then
    itemIndex = collection.IndexOf(testNamespace)
End If

適用於

另請參閱