AttributeCollection.Matches Method (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(
	Attribute[] attributes
)

Parameters

attributes
Type: 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.
   Attribute[] myAttrArray = new 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

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft