CodeExpressionCollection.Contains(CodeExpression) Metod

Definition

Hämtar ett värde som anger om samlingen innehåller det angivna CodeExpression objektet.

public:
 bool Contains(System::CodeDom::CodeExpression ^ value);
public bool Contains(System.CodeDom.CodeExpression value);
member this.Contains : System.CodeDom.CodeExpression -> bool
Public Function Contains (value As CodeExpression) As Boolean

Parametrar

value
CodeExpression

Objektet CodeExpression som ska hittas i samlingen.

Returer

trueom samlingen innehåller det angivna objektet; annars . false

Exempel

I följande exempel används Contains metoden för att söka efter förekomsten av ett specifikt CodeExpression objekt och hämtar indexvärdet där det hittades.

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

Gäller för

Se även