Edit

Share via


CodeAttributeDeclarationCollection.IndexOf(CodeAttributeDeclaration) Method

Definition

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

C#
public int IndexOf(System.CodeDom.CodeAttributeDeclaration value);

Parameters

value
CodeAttributeDeclaration

The CodeAttributeDeclaration object to locate in the collection.

Returns

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

Examples

The following example searches for the presence of a specific CodeAttributeDeclaration instance and uses the IndexOf method to get the index value at which it was found.

C#
// Tests for the presence of a CodeAttributeDeclaration in
// the collection, and retrieves its index if it is found.
CodeAttributeDeclaration testdeclaration = new CodeAttributeDeclaration("DescriptionAttribute", new CodeAttributeArgument(new CodePrimitiveExpression("Test Description")) );
int itemIndex = -1;
if( collection.Contains( testdeclaration ) )
    itemIndex = collection.IndexOf( testdeclaration );

Applies to

See also