共用方式為


CodeTypeMemberCollection.IndexOf(CodeTypeMember) 方法

定義

請取得在指定的 CodeTypeMember 集合中的索引 (如果它存在於集合中)。

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

參數

value
CodeTypeMember

要在集合中尋找的 CodeTypeMember

傳回

如果找到的話,索引位於指定物件的集合中,否則為 -1。

範例

下列程式代碼範例會搜尋特定 CodeTypeMember 物件是否存在,並使用 IndexOf 方法來擷取找到它的索引值。

// 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

適用於

另請參閱