Επεξεργασία

Κοινή χρήση μέσω


CodeTypeMemberCollection.IndexOf(CodeTypeMember) Method

Definition

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

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

Parameters

value
CodeTypeMember

The CodeTypeMember to locate in the collection.

Returns

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

Examples

The following code example searches for the presence of a specific CodeTypeMember object and uses the IndexOf method to retrieve the index value at which it was found.

// Tests for the presence of a CodeTypeMember in the collection, 
// and retrieves its index if it is found.
CodeTypeMember^ testMember = gcnew CodeMemberField( "System.String","TestStringField" );
int itemIndex = -1;
if ( collection->Contains( testMember ) )
   itemIndex = collection->IndexOf( testMember );
// Tests for the presence of a CodeTypeMember in the collection,
// and retrieves its index if it is found.
CodeTypeMember testMember = new CodeMemberField("System.String", "TestStringField");
int itemIndex = -1;
if( collection.Contains( testMember ) )
    itemIndex = collection.IndexOf( testMember );
' Tests for the presence of a CodeTypeMember within the collection, and retrieves its index if it is within the collection.
Dim testMember = New CodeMemberField("System.String", "TestStringField")
Dim itemIndex As Integer = -1
If collection.Contains(testMember) Then
    itemIndex = collection.IndexOf(testMember)
End If

Applies to

See also