AttributeCollection.Contains 메서드

정의

이 특성 컬렉션에 지정된 특성 또는 특성 배열이 있는지 확인합니다.

오버로드

Contains(Attribute)

이 특성 컬렉션에 지정된 특성이 있는지 확인합니다.

Contains(Attribute[])

이 특성 컬렉션에 특성 배열의 지정된 특성이 모두 포함되어 있는지 확인합니다.

Contains(Attribute)

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

이 특성 컬렉션에 지정된 특성이 있는지 확인합니다.

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

매개 변수

attribute
Attribute

컬렉션에서 찾을 Attribute입니다.

반환

컬렉션에 해당 특성이 포함되어 있거나 해당 특성 형식에 대한 기본 특성이 있으면 true이고, 그렇지 않으면 false입니다.

예제

다음 코드 예제에서는 컬렉션에 있는지 여부를 확인 하려면을 BrowsableAttributetrue합니다. 가정 button1textBox1 폼에 만들었습니다.

protected:
   void ContainsAttribute()
   {
      // Creates a new collection and assigns it the attributes for button1.
      AttributeCollection^ attributes;
      attributes = TypeDescriptor::GetAttributes( button1 );
      
      // Sets an Attribute to the specific attribute.
      BrowsableAttribute^ myAttribute = BrowsableAttribute::Yes;

      if ( attributes->Contains( myAttribute ) )
      {
         textBox1->Text = "button1 has a browsable attribute.";
      }
      else
      {
         textBox1->Text = "button1 does not have a browsable attribute.";
      }
   }
private void ContainsAttribute() {
    // Creates a new collection and assigns it the attributes for button1.
    AttributeCollection attributes;
    attributes = TypeDescriptor.GetAttributes(button1);

    // Sets an Attribute to the specific attribute.
    BrowsableAttribute myAttribute = BrowsableAttribute.Yes;

    if (attributes.Contains(myAttribute))
       textBox1.Text = "button1 has a browsable attribute.";
    else
       textBox1.Text = "button1 does not have a browsable attribute.";
 }
Private Sub ContainsAttribute
    ' Creates a new collection and assigns it the attributes for button.
    Dim attributes As AttributeCollection
    attributes = TypeDescriptor.GetAttributes(button1)

    ' Sets an Attribute to the specific attribute.
    Dim myAttribute As BrowsableAttribute = BrowsableAttribute.Yes

    If Attributes.Contains(myAttribute) Then
        textBox1.Text = "button1 has a browsable attribute."
    Else
        textBox1.Text = "button1 does not have a browsable attribute."
    End If
End Sub

설명

이 컬렉션 지정 된 특성이 지정된 된 형식의 특성 컬렉션에 있으면이 고 지정된 된 특성의 값이 컬렉션에 있는 특성의 인스턴스 값과 동일 합니다.

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

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

추가 정보

적용 대상

Contains(Attribute[])

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

이 특성 컬렉션에 특성 배열의 지정된 특성이 모두 포함되어 있는지 확인합니다.

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

매개 변수

attributes
Attribute[]

컬렉션에서 찾을 Attribute 형식의 배열입니다.

반환

컬렉션에 모든 특성이 포함되어 있으면 true이고 그렇지 않으면 false입니다.

예제

특성을 비교 하는 다음 코드 예제 button1textBox1 단추에 대 한 특성 텍스트 상자에 대 한 특성에 포함 되어 있는지 여부를 확인 합니다. 가정 하는 두 button1textBox1 폼에 만들었습니다.

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.";
      }
   }
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.
   Attribute[] myAttrArray = new 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.";
}
Private Sub ContainsAttributes()
    ' 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 are the attributes for textBox1.
    Dim myAttrArray(100) As Attribute
    TypeDescriptor.GetAttributes(textBox1).CopyTo(myAttrArray, 0)
    If myCollection.Contains(myAttrArray) Then
        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."
    End If
End Sub

설명

이 컬렉션에 지정한 특성 배열을 컬렉션에 있는 모든 지정 된 특성 형식 및 지정 된 배열의 각 특성의 특성 컬렉션에 같은 경우

추가 정보

적용 대상