AttributeCollection.Item[] Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Belirtilen dizine sahip özniteliği alır.
Aşırı Yüklemeler
Item[Int32] |
Belirtilen dizin numarasına sahip özniteliği alır. |
Item[Type] |
Belirtilen türe sahip özniteliği alır. |
Item[Int32]
- Kaynak:
- AttributeCollection.cs
- Kaynak:
- AttributeCollection.cs
- Kaynak:
- AttributeCollection.cs
Belirtilen dizin numarasına sahip özniteliği alır.
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
Parametreler
- index
- Int32
sıfır tabanlı dizini.AttributeCollection
Özellik Değeri
Attribute Belirtilen dizin numarasına sahip olan.
Örnekler
Aşağıdaki kod örneği, dizin numarası tarafından belirtilen adı Attribute bir metin kutusuna yazdırmak için özelliğini kullanırItem[]. Dizin numarası sıfır tabanlı olduğundan, bu kod örneği ikincinin Attribute adını bir metin kutusuna yazdırır. Bir formda oluşturulduğunu varsayarbutton1
.textBox1
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
Açıklamalar
Dizin numarası sıfır tabanlıdır. Bu nedenle, bu öğesine erişmek Attributeiçin belirli Attribute bir öğesinin sayısal konumundan 1 çıkarmanız gerekir. Örneğin, üçüncü Attributedeğerini almak için belirtmeniz myColl[2]
gerekir.
Ayrıca bkz.
Şunlara uygulanır
Item[Type]
- Kaynak:
- AttributeCollection.cs
- Kaynak:
- AttributeCollection.cs
- Kaynak:
- AttributeCollection.cs
Belirtilen türe sahip özniteliği alır.
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
Parametreler
Özellik Değeri
Attribute belirtilen türe sahip veya özniteliği yoksa, öznitelik türü için varsayılan değerdir.
Örnekler
Aşağıdaki kod örneği koleksiyondan öğesini DesignerAttribute alır ve değerini yazdırır. Ve'nin button1
textBox1
bir formda oluşturulduğunu varsayar.
Bu kod örneğinin çalışması için, tam derleme adını sağlamanız gerekir. Tam derleme adını alma hakkında bilgi için bkz. Derleme Adları.
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
Açıklamalar
Öznitelik koleksiyonda yoksa, bu özellik öznitelik türü için varsayılan değeri döndürür.