次の方法で共有


CodeExpressionCollection.IndexOf メソッド

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

Public Function IndexOf( _
   ByVal value As CodeExpression _) As Integer
[C#]
public int IndexOf(CodeExpressionvalue);
[C++]
public: int IndexOf(CodeExpression* value);
[JScript]
public function IndexOf(
   value : CodeExpression) : int;

パラメータ

戻り値

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

使用例

 
' Tests for the presence of a CodeExpression in the 
' collection, and retrieves its index if it is found.
Dim testComment = New CodePrimitiveExpression(True)
Dim itemIndex As Integer = -1
If collection.Contains(testComment) Then
    itemIndex = collection.IndexOf(testComment)
End If

[C#] 
// Tests for the presence of a CodeExpression in the 
// collection, and retrieves its index if it is found.
CodeExpression testComment = new CodePrimitiveExpression(true);
int itemIndex = -1;
if( collection.Contains( testComment ) )
    itemIndex = collection.IndexOf( testComment );

[C++] 
// Tests for the presence of a CodeExpression in the 
// collection, and retrieves its index if it is found.
CodeExpression* testComment = new CodePrimitiveExpression(__box(true));
int itemIndex = -1;
if( collection->Contains( testComment ) )
    itemIndex = collection->IndexOf( testComment );

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

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