CodeCommentStatementCollection.IndexOf(CodeCommentStatement) Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Hämtar indexet för det angivna CodeCommentStatement objektet i samlingen, om det finns i samlingen.
public:
int IndexOf(System::CodeDom::CodeCommentStatement ^ value);
public int IndexOf(System.CodeDom.CodeCommentStatement value);
member this.IndexOf : System.CodeDom.CodeCommentStatement -> int
Public Function IndexOf (value As CodeCommentStatement) As Integer
Parametrar
- value
- CodeCommentStatement
Objektet CodeCommentStatement som ska hittas.
Returer
Indexet för det angivna objektet, om det hittas, i samlingen; annars -1.
Exempel
I följande exempel söker du efter förekomsten av ett specifikt CodeCommentStatement objekt och använder IndexOf metoden för att hämta indexvärdet som det hittades på.
// Tests for the presence of a CodeCommentStatement in the
// collection, and retrieves its index if it is found.
CodeCommentStatement testComment = new CodeCommentStatement("Test comment");
int itemIndex = -1;
if( collection.Contains( testComment ) )
itemIndex = collection.IndexOf( testComment );
' Tests for the presence of a CodeCommentStatement in the
' collection, and retrieves its index if it is found.
Dim testComment As New CodeCommentStatement("Test comment")
Dim itemIndex As Integer = -1
If collection.Contains(testComment) Then
itemIndex = collection.IndexOf(testComment)
End If