DynamicMethod.GetCustomAttributes Method

Definition

Returns the custom attributes applied to the method.

Overloads

GetCustomAttributes(Boolean)

Returns all the custom attributes defined for the method.

GetCustomAttributes(Type, Boolean)

Returns the custom attributes of the specified type that have been applied to the method.

GetCustomAttributes(Boolean)

Source:
DynamicMethod.cs
Source:
DynamicMethod.cs
Source:
DynamicMethod.cs

Returns all the custom attributes defined for the method.

C#
public override object[] GetCustomAttributes(bool inherit);

Parameters

inherit
Boolean

true to search the method's inheritance chain to find the custom attributes; false to check only the current method.

Returns

Object[]

An array of objects representing all the custom attributes of the method.

Remarks

For dynamic methods, specifying true for inherit has no effect, because the method is not declared in a type.

Napomena

Custom attributes are not currently supported on dynamic methods. The only attribute returned is MethodImplAttribute; you can get the method implementation flags more easily using the GetMethodImplementationFlags method.

See also

Applies to

.NET 10 i druge verzije
Proizvod Verzije
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided), 2.1

GetCustomAttributes(Type, Boolean)

Source:
DynamicMethod.cs
Source:
DynamicMethod.cs
Source:
DynamicMethod.cs

Returns the custom attributes of the specified type that have been applied to the method.

C#
public override object[] GetCustomAttributes(Type attributeType, bool inherit);

Parameters

attributeType
Type

A Type representing the type of custom attribute to return.

inherit
Boolean

true to search the method's inheritance chain to find the custom attributes; false to check only the current method.

Returns

Object[]

An array of objects representing the attributes of the method that are of type attributeType or derive from type attributeType.

Exceptions

attributeType is null.

Remarks

For dynamic methods, specifying true for inherit has no effect, because the method is not declared in a type.

Napomena

Custom attributes are not currently supported on dynamic methods. The only attribute returned is MethodImplAttribute; you can get the method implementation flags more easily using the GetMethodImplementationFlags method.

See also

Applies to

.NET 10 i druge verzije
Proizvod Verzije
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided), 2.1