CodeTypeDeclarationCollection.IndexOf(CodeTypeDeclaration) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得 CodeTypeDeclaration 中指定之 CodeTypeDeclarationCollection 物件的索引 (如果它存在於集合中的話)。
public:
int IndexOf(System::CodeDom::CodeTypeDeclaration ^ value);
public int IndexOf (System.CodeDom.CodeTypeDeclaration value);
member this.IndexOf : System.CodeDom.CodeTypeDeclaration -> int
Public Function IndexOf (value As CodeTypeDeclaration) As Integer
參數
- value
- CodeTypeDeclaration
要在集合中尋找的 CodeTypeDeclaration。
傳回
如果找到的話,就是集合中指定之物件的索引,否則為 -1。
範例
下列範例會 CodeTypeDeclaration 從 CodeTypeDeclarationCollection 物件擷取專案,並顯示方法傳 IndexOf 回的名稱和索引。
// Tests for the presence of a CodeTypeDeclaration in the
// collection, and retrieves its index if it is found.
CodeTypeDeclaration^ testDeclaration = gcnew CodeTypeDeclaration( "TestType" );
int itemIndex = -1;
if ( collection->Contains( testDeclaration ) )
itemIndex = collection->IndexOf( testDeclaration );
// 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 );
' Tests for the presence of a CodeTypeDeclaration in the
' collection, and retrieves its index if it is found.
Dim testDeclaration As New CodeTypeDeclaration("TestType")
Dim itemIndex As Integer = -1
If collection.Contains(testDeclaration) Then
itemIndex = collection.IndexOf(testDeclaration)
End If