Documente Academic
Documente Profesional
Documente Cultură
C# gives us a new, flexible solution to associate information with some class, named attributes.
For example:
[Serializable]
class Max
{
public int x,y;
}
Here the attribute informs us that, Class "Max" may be serialized in some point of time. Such
additional information about our class may help us remember, What is this class all about? But,
.NET says more: attributes can be queried at runtime!
At first, we must understand, that attributes are simply classes that derives from
System.Attribute.
By writing those lines we have defined custom attribute! Let's use it:
[Meou("No reason")] // normal cats say meou without reason
public class Cat
{
}