CodeTypeDeclarationCollection.IndexOf Method (CodeTypeDeclaration)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets the index of the specified CodeTypeDeclaration object in the CodeTypeDeclarationCollection, if it exists in the collection.

Namespace:   System.CodeDom
Assembly:  System (in System.dll)

public int IndexOf(
	CodeTypeDeclaration value


Type: System.CodeDom.CodeTypeDeclaration

The CodeTypeDeclaration to locate in the collection.

Return Value

Type: System.Int32

The index of the specified object, if it is found, in the collection; otherwise, -1.

The following example retrieves CodeTypeDeclaration entries from a CodeTypeDeclarationCollection object and displays their names and indexes returned by the IndexOf method.

// Tests for the presence of a CodeTypeDeclaration in the 
// collection, and retrieves its index if it is found.
CodeTypeDeclaration testDeclaration = new CodeTypeDeclaration("TestType");
int itemIndex = -1;
if( collection.Contains( testDeclaration ) )
    itemIndex = collection.IndexOf( testDeclaration );

.NET Framework
Available since 1.1
Return to top