Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

AttributeCollection::Matches Method (array<Attribute^>^)

 

Determines whether the attributes in the specified array are the same as the attributes in the collection.

Namespace:   System.ComponentModel
Assembly:  System (in System.dll)

public:
bool Matches(
	array<Attribute^>^ attributes
)

Parameters

attributes
Type: array<System::Attribute^>^

An array of MemberAttributes to compare with the attributes in this collection.

Return Value

Type: System::Boolean

true if all the attributes in the array are contained in the collection and have the same values as the attributes in the collection; otherwise, false.

An attribute can provide support for matching.

The following code example compares the attributes in a button and a text box to see whether they match. It assumes that button1 and textBox1 have been created on a form.

private:
   void MatchesAttributes()
   {
      // 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 match the attributes for textBox1.
      array<Attribute^>^ myAttrArray = gcnew array<Attribute^>(100);
      TypeDescriptor::GetAttributes( textBox1 )->CopyTo( myAttrArray, 0 );
      if ( myCollection->Matches( myAttrArray ) )
      {
         textBox1->Text = "The attributes in the button and text box match.";
      }
      else
      {
         textBox1->Text = "The attributes in the button and text box do not match.";
      }
   }

.NET Framework
Available since 1.1
Return to top
Show:
© 2017 Microsoft