The .NET Framework defines more than 500 attribute classes, so only a handful of the most commonly used are described here.
The names of attribute classes end with
Attribute. If you want to search for an attribute’s class, add
Attribute to the end of the name. For example, the
ReadOnly attribute class’s name is
To create a custom attribute, simply create a new class derived from the
Attribute class. By convention, the custom attribute class’s name should end with
For more information about attributes, see msdn.microsoft.com/library/system.attribute.aspx. If you scroll to the bottom, you can see a list of classes that inherit from the
The following table lists attributes that are useful when performing XML serializations.
|Indicates the name that should be given to an array in an XML serialization.|
|Indicates a type that can be in an array in an XML serialization.|
|Indicates that a property should be serialized as an attribute rather than an element in an XML serialization. Optionally indicates the attribute’s name in the serialization.|
|Specifically indicates the field will be serialized as an XML element. This attribute allows you to change the XML element’s name.|
|Enables you to specify the names by which enumeration values are serialized.|
|Indicates that an XML serialization should not ...|