Attributes
Attributes provide meta-information about assemblies, types, and members. This meta-information is consumed by the compiler, the CLR, or tools that use reflection services to read them. Attributes are actually types that derive from the System.Attribute
abstract class. The .NET frameworks provide a large number of attributes, but users can define their own.
Attributes are specified in square brackets, such as in [SerializableAttribute]
. The naming convention for attributes is that the type names are always suffixed with the word Attribute
. The C# language provides a syntactic shortcut that allows specifying the name of the attribute without the suffix, Attribute
, such as in [Serializable]
. However, this is only possible as long as the type name is properly suffixed according to this convention.
We will first look at some widely used system attributes in the next section.
System attributes
.NET Framework provides hundreds of attributes in different assemblies...