[ Team LiB ] Previous Section Next Section

AttributeUsageAttributeCF 1.0, ECMA 1.0, serializable

System (mscorlib.dll)sealed class

This attribute is used when developing a custom attribute class. It allows you to specify how your custom attribute must be used. The ValidOn property uses a bitwise combination of values from AttributeTargets to specify the code elements that can use your custom attribute. It's read-only and must be initialized using the constructor, as in [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)].

The AllowMultiple property specifies whether the attribute can be used more than once for the same element. The Inherited attribute specifies whether your custom attribute will be applied to derived classes and overridden members. These are indicated using the usual named parameter syntax supported by attributes, as in [AttributeUsage(Inherited = true, AllowMultiple = true)].

public sealed class AttributeUsageAttribute : Attribute {
// Public Constructors
   public AttributeUsageAttribute(AttributeTargets validOn);
// Public Instance Properties
   public bool AllowMultiple{set; get; }
   public bool Inherited{set; get; }
   public AttributeTargets ValidOn{get; }
}

Hierarchy

Object Attribute AttributeUsageAttribute

Valid On

Class

    [ Team LiB ] Previous Section Next Section