Gets the attribute with the specified type.
[C#] In C#, this member is the indexer for the MemberAttributeCollection class.
[Visual Basic] Overloads Overridable Public Default ReadOnly Property Item( _ ByVal attributeType As Type _ ) As MemberAttribute [C#] public MemberAttribute this[ Type attributeType ] {virtual get;} [C++] public: __property virtual MemberAttribute* get_Item( Type* attributeType ); [JScript] returnValue = MemberAttributeCollectionObject.Item(attributeType); -or- returnValue = MemberAttributeCollectionObject(attributeType);
[JScript] In JScript, you can use the default indexed properties defined by a type, but you cannot explicitly define your own. However, specifying the expando attribute on a class automatically provides a default indexed Item property whose type is Object and whose index type is String.
The MemberAttribute with the specified type, or if the attribute does not exist, the default value for the attributeType.
If the attribute does not exist in the collection, this property returns the default value for the attributeType.
The following example gets the DescriptionAttribute from the collection and prints its value. It assumes that Button1 has been instantiated on a form.
[Visual Basic]
Private Sub PrintIndexItem2() 'Create a new collection and assign it the attributes for Button1. Dim attributes As MemberAttributeCollection attributes = TypeDescriptor.GetAttributes(Button1) 'Get the description attribute from the collection. Dim myDescription As DescriptionAttribute myDescription = CType(attributes.Item(GetType(System.ComponentModel.DescriptionAttribute)), DescriptionAttribute) 'Print the value of the attribute in a text box. TextBox1.Text = myDescription.GetDescription End Sub
MemberAttributeCollection Class | MemberAttributeCollection Members | System.ComponentModel Namespace | MemberAttributeCollection.Item Overload List | MemberAttribute