System.ComponentModel.AttributeCollection.Matches Method

Determines whether a specified attribute is the same as an attribute in the collection.

Syntax

public bool Matches (Attribute attr)

Parameters

attr
Documentation for this section has not yet been entered.

Returns

true if the attribute is contained within the collection and has the same value as the attribute in the collection; otherwise, false.

Remarks

An attribute can provide support for matching.

The difference between the AttributeCollection.Matches(Attribute) and AttributeCollection.Contains(Attribute) methods is that AttributeCollection.Matches(Attribute) calls the Attribute.Match(object) method on an attribute, and AttributeCollection.Contains(Attribute) calls the object.Equals(object) method.

For most attributes, these methods do the same thing. For attributes that may have multiple flags, however, Attribute.Match(object) is typically implemented so that it returns true if any of the flags are satisfied. For example, consider a data binding attribute with the Boolean flags "SupportsSql", "SupportsOleDb", and "SupportsXml". This attribute may be present on a property that supports all three data binding approaches. It will often be the case that a programmer needs to know only if a particular approach is available, not all three. Therefore, a programmer could use Attribute.Match(object) with an instance of the attribute containing only the flags the programmer needs.

Requirements

Namespace: System.ComponentModel
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0