AttributeCollection::Contains Method (array<Attribute^>^)
Determines whether this attribute collection contains all the specified attributes in the attribute array.
Assembly: System (in System.dll)
Parameters
- attributes
-
Type:
array<System::Attribute^>^
An array of type Attribute to find in the collection.
Return Value
Type: System::Booleantrue if the collection contains all the attributes; otherwise, false.
This collection has the specified array of attributes if all the specified attribute types exist in the collection and if each attribute in the specified array is the same as an attribute in the collection.
The following code example compares the attributes in button1 and textBox1 to see whether the attributes for the button are contained in the attributes for the text box. It assumes that both button1 and textBox1 have been created on a form.
private: void ContainsAttributes() { // Creates a new collection and assigns it the attributes for button1. AttributeCollection^ myCollection; myCollection = TypeDescriptor::GetAttributes( button1 ); // Checks to see whether the attributes in myCollection are the attributes for textBox1. array<Attribute^>^ myAttrArray = gcnew array<Attribute^>(100); TypeDescriptor::GetAttributes( textBox1 )->CopyTo( myAttrArray, 0 ); if ( myCollection->Contains( myAttrArray ) ) { textBox1->Text = "Both the button and text box have the same attributes."; } else { textBox1->Text = "The button and the text box do not have the same attributes."; } }
Available since 1.1