Attribute
In this chapter you will learn:
Get to know attribute
You can add declarative information to a program by using an attribute. An attribute defines additional information that is associated with a class, structure, method, and so on.
An attribute is supported by a class that inherits System.Attribute
.
All attribute classes must be subclasses of System.Attribute
.
This built-in attribute AttributeUsage
specifies the types of
items to which the attribute can be applied.
using System.Diagnostics;
/* j a v a2 s .c o m*/
class MainClass
{
[Conditional("DEBUG")]
public void Validate()
{
}
}
Next chapter...
What you will learn in the next chapter: