CodeTypeMemberCollection.IndexOf(CodeTypeMember) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
請取得在指定的 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