AttributeCollection.Matches 메서드

정의

지정된 특성 또는 특성 배열이 컬렉션의 특성 또는 특성 배열과 같은지 확인합니다.

오버로드

Matches(Attribute)

지정된 특성이 컬렉션의 특성과 같은지 확인합니다.

Matches(Attribute[])

지정된 배열의 특성이 컬렉션의 특성과 같은지 확인합니다.

Matches(Attribute)

Source:
AttributeCollection.cs
Source:
AttributeCollection.cs
Source:
AttributeCollection.cs

지정된 특성이 컬렉션의 특성과 같은지 확인합니다.

public:
 bool Matches(Attribute ^ attribute);
public bool Matches (Attribute attribute);
public bool Matches (Attribute? attribute);
member this.Matches : Attribute -> bool
Public Function Matches (attribute As Attribute) As Boolean

매개 변수

attribute
Attribute

이 컬렉션의 특성과 비교할 Attribute의 인스턴스입니다.

반환

해당 특성이 컬렉션 내에 포함되어 있으며 컬렉션의 특성과 같은 값을 가지면 true이고, 그렇지 않으면 false입니다.

예제

다음 코드 예제를 확인 하는 BrowsableAttribute 컬렉션의 멤버인 및로 설정한 true합니다. 가정 button1textBox1 폼에 만들었습니다.

private:
   void MatchesAttribute()
   {
      // Creates a new collection and assigns it the attributes for button1.
      AttributeCollection^ attributes;
      attributes = TypeDescriptor::GetAttributes( button1 );
      
      // Checks to see if the browsable attribute is true.
      if ( attributes->Matches( BrowsableAttribute::Yes ) )
      {
         textBox1->Text = "button1 is browsable.";
      }
      else
      {
         textBox1->Text = "button1 is not browsable.";
      }
   }
private void MatchesAttribute() {
    // Creates a new collection and assigns it the attributes for button1.
    AttributeCollection attributes;
    attributes = TypeDescriptor.GetAttributes(button1);

    // Checks to see if the browsable attribute is true.
    if (attributes.Matches(BrowsableAttribute.Yes))
       textBox1.Text = "button1 is browsable.";
    else
       textBox1.Text = "button1 is not browsable.";
 }
Private Sub MatchesAttribute
    ' Creates a new collection and assigns it the attributes for button
    Dim attributes As AttributeCollection
    attributes = TypeDescriptor.GetAttributes(button1)

    ' Checks to see if the browsable attribute is true.
    If attributes.Matches(BrowsableAttribute.Yes) Then
        textBox1.Text = "button1 is browsable."
    Else
        textBox1.Text = "button1 is not browsable."
    End If
End Sub

설명

특성에는 일치에 대 한 지원을 제공할 수 있습니다.

간의 차이 MatchesContains 메서드는 Matches 호출을 Match 특성에 대 한 메서드 및 Contains 호출은 Equals 메서드.

이러한 메서드는 대부분의 특성에 대 한 동일한 작업을 수행 합니다. 그러나 여러 플래그를 가질 수 있는 특성에 대 한 Match 일반적으로 반환 되도록 구현 됩니다 true 플래그 중 하나라도 충족 되 면 합니다. 예를 들어, "SupportsSql", "SupportsOleDb" 및 "SupportsXml" 부울 플래그를 사용 하 여 데이터 바인딩 특성을 고려 합니다. 이 특성은 세 가지 데이터 바인딩 방법을 모두 지 원하는 속성에 존재할 수 있습니다. 프로그래머가 특정 접근 방식을 사용할 경우 확인 해야 하는 경우 종종 됩니다 모든 3입니다. 프로그래머가 사용할 수 있으므로 Match 프로그래머가 플래그를 포함 하는 특성의 인스턴스를 사용 하 여 해야 합니다.

추가 정보

적용 대상

Matches(Attribute[])

Source:
AttributeCollection.cs
Source:
AttributeCollection.cs
Source:
AttributeCollection.cs

지정된 배열의 특성이 컬렉션의 특성과 같은지 확인합니다.

public:
 bool Matches(cli::array <Attribute ^> ^ attributes);
public bool Matches (Attribute[] attributes);
public bool Matches (Attribute[]? attributes);
member this.Matches : Attribute[] -> bool
Public Function Matches (attributes As Attribute()) As Boolean

매개 변수

attributes
Attribute[]

이 컬렉션의 특성과 비교할 MemberAttributes의 배열입니다.

반환

배열의 모든 특성이 해당 컬렉션에 포함되어 있으며 해당 컬렉션의 특성과 같은 값을 가지고 있으면 true이고, 그렇지 않으면 false입니다.

예제

다음 코드 예제는 단추와 일치 하는지 여부를 확인 하려면 텍스트 상자에 있는 특성을 비교 합니다. 가정 button1textBox1 폼에 만들었습니다.

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.";
      }
   }
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.";
}
Private Sub MatchesAttributes()
    ' Creates a new collection and assigns it the attributes for button1.
    Dim myCollection As AttributeCollection
    myCollection = TypeDescriptor.GetAttributes(button1)
       
    ' Checks to see whether the attributes in myCollection match the attributes.
    ' for textBox1.
    Dim myAttrArray(100) As Attribute
    TypeDescriptor.GetAttributes(textBox1).CopyTo(myAttrArray, 0)
    If myCollection.Matches(myAttrArray) Then
        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."
    End If
End Sub

설명

특성에는 일치에 대 한 지원을 제공할 수 있습니다.

추가 정보

적용 대상