AttributeUsage
attribute CS-W1070The AttributeUsage
attribute allows you to specify where your attribute can be used, whether it should be used for a class
, struct
, or some other entity. If you're defining your own attributes, consider using AttributeUsage
.
class MyCustomAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Class)] // Should be used ideally only for classes
class MyCustomAttribute : Attribute
{
}