Open sandboxFocus

Method HasCustomAttribute

HasCustomAttribute(object, Type, bool)

Determines whether a declaration has a custom attribute of a given type, including those who have been added indirectly, for instance through MulticastAttribute.

Declaration
public static bool HasCustomAttribute(object target, Type type, bool inherit = false)
Parameters
Type Name Description
object target

Element of code (Type, MethodInfo, ...) whose custom attributes are requested.

Type type

The type of custom attributes.

bool inherit

true to consider custom attributes derived from type, false to consider only custom attributes strictly of type type.

Returns
Type Description
bool

True if type has a custom attribute of type type, otherwise false.