AttributeCollection.Item[] 속성

정의

지정된 인덱스가 있는 특성을 가져옵니다.

오버로드

Item[Int32]

지정된 인덱스 번호가 있는 특성을 가져옵니다.

Item[Type]

지정된 형식의 특성을 가져옵니다.

Item[Int32]

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

지정된 인덱스 번호가 있는 특성을 가져옵니다.

public:
 virtual property Attribute ^ default[int] { Attribute ^ get(int index); };
public virtual Attribute this[int index] { get; }
member this.Item(int) : Attribute
Default Public Overridable ReadOnly Property Item(index As Integer) As Attribute

매개 변수

index
Int32

AttributeCollection의 인덱스이며 0에서 시작합니다.

속성 값

지정된 인덱스 번호가 있는 Attribute입니다.

예제

다음 코드 예제에서는 합니다 Item[] 속성의 이름을 출력 하는 Attribute 텍스트 상자에 인덱스 번호로 지정 된 합니다. 이 코드 예제에서는 두 번째 이름을 인쇄 인덱스 번호를 0부터 시작 되므로, Attribute 텍스트 상자에 있습니다. 가정 button1textBox1 폼에 만들었습니다.

private:
   void PrintIndexItem()
   {
      // Creates a new collection and assigns it the attributes for button1.
      AttributeCollection^ attributes;
      attributes = TypeDescriptor::GetAttributes( button1 );
      
      // Prints the second attribute's name.
      textBox1->Text = attributes[ 1 ]->ToString();
   }
private void PrintIndexItem() {
    // Creates a new collection and assigns it the attributes for button1.
    AttributeCollection attributes;
    attributes = TypeDescriptor.GetAttributes(button1);

    // Prints the second attribute's name.
    textBox1.Text = attributes[1].ToString();
 }
Private Sub PrintIndexItem
    ' Creates a new collection and assigns it the attributes for button1.
    Dim attributes As AttributeCollection
    attributes = TypeDescriptor.GetAttributes(button1)

    ' Prints the second attribute's name.
    textBox1.Text = attributes(1).ToString
End Sub

설명

인덱스 번호는 0부터 시작 합니다. 따라서 특정 숫자 위치에서 1 빼야 Attribute 에 액세스 하려면 해당 Attribute합니다. 예를 들어, 세 번째 가져오려는 Attribute를 지정 해야 myColl[2]합니다.

추가 정보

적용 대상

Item[Type]

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

지정된 형식의 특성을 가져옵니다.

public:
 virtual property Attribute ^ default[Type ^] { Attribute ^ get(Type ^ attributeType); };
public virtual Attribute this[Type attributeType] { get; }
public virtual Attribute? this[Type attributeType] { get; }
member this.Item(Type) : Attribute
Default Public Overridable ReadOnly Property Item(attributeType As Type) As Attribute

매개 변수

attributeType
Type

목록에서 가져올 TypeAttribute입니다.

속성 값

지정된 형식의 Attribute이거나, 해당 특성이 없으면 해당 특성 형식의 기본값입니다.

예제

다음 코드 예제에서는 DesignerAttribute 컬렉션에서 해당 값을 출력 합니다. 가정 button1textBox1 폼에 만들었습니다.

이 코드 예제를 실행 하려면 정규화 된 어셈블리 이름을 제공 해야 합니다. 참조 된 정규화 된 어셈블리 이름을 가져오는 방법에 대 한 내용은 어셈블리 이름합니다.

void PrintIndexItem2()
{
   
   // Creates a new collection and assigns it the attributes for button1.
   AttributeCollection^ attributes;
   attributes = TypeDescriptor::GetAttributes( button1 );
   
   // Gets the designer attribute from the collection.
   DesignerAttribute^ myDesigner;
   
   // You must supply a valid fully qualified assembly name here. 
   myDesigner = dynamic_cast<DesignerAttribute^>(attributes[ Type::GetType(  "Assembly text name, Version, Culture, PublicKeyToken" ) ]);
   textBox1->Text = myDesigner->DesignerTypeName;
}
private void PrintIndexItem2() {
    // Creates a new collection and assigns it the attributes for button1.
    AttributeCollection attributes;
    attributes = TypeDescriptor.GetAttributes(button1);
 
    // Gets the designer attribute from the collection.
    DesignerAttribute myDesigner; 
    // You must supply a valid fully qualified assembly name here. 
    myDesigner = (DesignerAttribute)attributes[Type.GetType("Assembly text name, Version, Culture, PublicKeyToken")];
    textBox1.Text = myDesigner.DesignerTypeName;
 }
Private Sub PrintIndexItem2
    ' Creates a new collection and assigns it the attributes for button1.
    Dim attributes As AttributeCollection
    attributes = TypeDescriptor.GetAttributes(button1)

    ' Gets the designer attribute from the collection.
    Dim myDesigner As DesignerAttribute
            ' You must supply a valid fully qualified assembly name here. 
    myDesigner = CType(attributes(Type.GetType("Assembly text name, Version, Culture, PublicKeyToken")), DesignerAttribute)
    textBox1.Text = myDesigner.DesignerTypeName
End Sub

설명

특성 컬렉션에 없으면이 속성 특성 형식에 대 한 기본값을 반환 합니다.

추가 정보

적용 대상