This documentation is archived and is not being maintained.

Attribute.GetCustomAttributes Method (MemberInfo, Type)

.NET Framework 1.1

Retrieves an array of the custom attributes of a specified type applied to a specified member of a class or inherited from a base class.

[Visual Basic]
Overloads Public Shared Function GetCustomAttributes( _
   ByVal element As MemberInfo, _
   ByVal type As Type _
) As Attribute()
[C#]
public static Attribute[] GetCustomAttributes(
 MemberInfo element,
 Type type
);
[C++]
public: static Attribute* GetCustomAttributes(
 MemberInfo* element,
 Type* type
) [];
[JScript]
public static function GetCustomAttributes(
   element : MemberInfo,
 type : Type
) : Attribute[];

Parameters

element
An object derived from class MemberInfo that describes a constructor, event, field, method, or property member of a class.
type
The Type object to which the custom attributes are applied.

Return Value

An Attribute array containing the custom attributes of type type applied to element.

-or-

An empty array if no such custom attributes exist.

Exceptions

Exception Type Condition
ArgumentNullException element or type is a null reference (Nothing in Visual Basic).
ArgumentException type is not derived from Attribute.
NotSupportedException element is not a constructor, method, property, event, type, or field.

Remarks

Return value contains the custom attributes for ancestors of element.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Attribute Class | Attribute Members | System Namespace | Attribute.GetCustomAttributes Overload List

Show: