This documentation is archived and is not being maintained.

Attribute.GetCustomAttribute Method

Retrieves a custom attribute of a specified type applied to a specified member of a class.

Overload List

Retrieves a custom attribute of a specified type applied to a specified assembly or inherited from a base class.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Shared Function GetCustomAttribute(Assembly, Type) As Attribute
[C#] public static Attribute GetCustomAttribute(Assembly, Type);
[C++] public: static Attribute* GetCustomAttribute(Assembly*, Type*);
[JScript] public static function GetCustomAttribute(Assembly, Type) : Attribute;

Retrieves a custom attribute of a specified type applied to a specified member of a class or inherited from a base class.

Supported by the .NET Compact Framework.

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

Retrieves a custom attribute of a specified type applied to a specified module or inherited from a base class.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Shared Function GetCustomAttribute(Module, Type) As Attribute
[C#] public static Attribute GetCustomAttribute(Module, Type);
[C++] public: static Attribute* GetCustomAttribute(Module*, Type*);
[JScript] public static function GetCustomAttribute(Module, Type) : Attribute;

Retrieves a custom attribute of a specified type applied to a specified parameter of a member of a class or inherited from a base class.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Shared Function GetCustomAttribute(ParameterInfo, Type) As Attribute
[C#] public static Attribute GetCustomAttribute(ParameterInfo, Type);
[C++] public: static Attribute* GetCustomAttribute(ParameterInfo*, Type*);
[JScript] public static function GetCustomAttribute(ParameterInfo, Type) : Attribute;

Retrieves a custom attribute of a specified type applied to a specified assembly or optionally inherited from a base class.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Shared Function GetCustomAttribute(Assembly, Type, Boolean) As Attribute
[C#] public static Attribute GetCustomAttribute(Assembly, Type, bool);
[C++] public: static Attribute* GetCustomAttribute(Assembly*, Type*, bool);
[JScript] public static function GetCustomAttribute(Assembly, Type, Boolean) : Attribute;

Retrieves a custom attribute of a specified type applied to a specified member of a class or optionally inherited from a base class.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Shared Function GetCustomAttribute(MemberInfo, Type, Boolean) As Attribute
[C#] public static Attribute GetCustomAttribute(MemberInfo, Type, bool);
[C++] public: static Attribute* GetCustomAttribute(MemberInfo*, Type*, bool);
[JScript] public static function GetCustomAttribute(MemberInfo, Type, Boolean) : Attribute;

Retrieves a custom attribute of a specified type applied to a specified module or optionally inherited from a base class.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Shared Function GetCustomAttribute(Module, Type, Boolean) As Attribute
[C#] public static Attribute GetCustomAttribute(Module, Type, bool);
[C++] public: static Attribute* GetCustomAttribute(Module*, Type*, bool);
[JScript] public static function GetCustomAttribute(Module, Type, Boolean) : Attribute;

Retrieves a custom attribute of a specified type applied to a specified parameter of a member of a class or optionally inherited from a base class.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Shared Function GetCustomAttribute(ParameterInfo, Type, Boolean) As Attribute
[C#] public static Attribute GetCustomAttribute(ParameterInfo, Type, bool);
[C++] public: static Attribute* GetCustomAttribute(ParameterInfo*, Type*, bool);
[JScript] public static function GetCustomAttribute(ParameterInfo, Type, Boolean) : Attribute;

Example

The following code example defines a custom parameter attribute class and applies the custom attribute to a method in a derived class and the derived class' base. The example shows the use of the GetCustomAttribute method to return the attributes.

[SampleID='System.Attribute.GetCustomAttribute' SnippetID='3']

See Also

Attribute Class | Attribute Members | System Namespace

Show: