共用方式為


CodeAttributeArgumentCollection.Contains(CodeAttributeArgument) 方法

定義

取得值,這個值表示集合是否包含指定的 CodeAttributeArgument 物件。

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

參數

value
CodeAttributeArgument

要放置在集合中的 CodeAttributeArgument 物件。

傳回

如果集合包含指定的物件,則為 true,否則為 false

範例

下列範例會Contains使用 方法來搜尋 中CodeAttributeArgumentCollection是否有特定CodeAttributeArgument物件,並取得找到它的索引值。

// Tests for the presence of a CodeAttributeArgument 
// within the collection, and retrieves its index if it is found.
CodeAttributeArgument^ testArgument = gcnew CodeAttributeArgument( "Test Boolean Argument",gcnew CodePrimitiveExpression( true ) );
int itemIndex = -1;
if ( collection->Contains( testArgument ) )
   itemIndex = collection->IndexOf( testArgument );
// Tests for the presence of a CodeAttributeArgument
// within the collection, and retrieves its index if it is found.
CodeAttributeArgument testArgument = new CodeAttributeArgument("Test Boolean Argument", new CodePrimitiveExpression(true));
int itemIndex = -1;
if( collection.Contains( testArgument ) )
    itemIndex = collection.IndexOf( testArgument );
' Tests for the presence of a CodeAttributeArgument in 
' the collection, and retrieves its index if it is found.
Dim testArgument As New CodeAttributeArgument("Test Boolean Argument", New CodePrimitiveExpression(True))
Dim itemIndex As Integer = -1
If collection.Contains(testArgument) Then
    itemIndex = collection.IndexOf(testArgument)
End If

適用於