次の方法で共有


CodeTypeDeclarationCollection.IndexOf メソッド

指定した CodeTypeDeclaration がコレクション内に存在する場合は、コレクション内でのそのインデックスを取得します。

名前空間: System.CodeDom
アセンブリ: System (system.dll 内)

構文

'宣言
Public Function IndexOf ( _
    value As CodeTypeDeclaration _
) As Integer
'使用
Dim instance As CodeTypeDeclarationCollection
Dim value As CodeTypeDeclaration
Dim returnValue As Integer

returnValue = instance.IndexOf(value)
public int IndexOf (
    CodeTypeDeclaration value
)
public:
int IndexOf (
    CodeTypeDeclaration^ value
)
public int IndexOf (
    CodeTypeDeclaration value
)
public function IndexOf (
    value : CodeTypeDeclaration
) : int

パラメータ

戻り値

見つかった場合はコレクション内での指定したオブジェクトのインデックス。それ以外の場合は -1。

使用例

' 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
// 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.
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);
}

プラットフォーム

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。

バージョン情報

.NET Framework

サポート対象 : 2.0、1.1、1.0

参照

関連項目

CodeTypeDeclarationCollection クラス
CodeTypeDeclarationCollection メンバ
System.CodeDom 名前空間
Contains