CodeNamespaceCollection.IndexOf(CodeNamespace) 方法
定义
获取指定的 CodeNamespace 对象在 CodeNamespaceCollection 中的索引(如果它已存在于该集合中)。Gets the index of the specified CodeNamespace object in the CodeNamespaceCollection, if it exists in the collection.
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。The CodeNamespace to locate.
返回
如果在该集合中找到指定 CodeNamespace,则为它在该集合中的索引;否则为 -1。The index of the specified CodeNamespace, if it is found, in the collection; otherwise, -1.
示例
下面的示例搜索特定的是否存在 CodeNamespace ,并使用 IndexOf 方法检索找到它的索引值。The following example searches for the presence of a specific CodeNamespace and uses the IndexOf method to retrieve the index value at which it was found.
// Tests for the presence of a CodeNamespace in the collection,
// and retrieves its index if it is found.
CodeNamespace^ testNamespace = gcnew 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.
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