CodeExpressionCollection.Contains(CodeExpression) 方法
定义
获取一个值,该值指示集合是否包含指定的 CodeExpression 对象。Gets a value that indicates whether the collection contains the specified CodeExpression object.
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
参数
- value
- CodeExpression
要在集合中定位的 CodeExpression 对象。The CodeExpression object to locate in the collection.
返回
当集合包含指定的对象时为 true;否则为 false。true if the collection contains the specified object; otherwise, false.
示例
下面的示例使用 Contains 方法来搜索特定对象的状态 CodeExpression ,并获取找到该对象时的索引值。The following example uses the Contains method to search for the presence of a specific CodeExpression object and gets the index value at which it was found.
// Tests for the presence of a CodeExpression in the
// collection, and retrieves its index if it is found.
CodeExpression^ testComment = gcnew 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.
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