Friday, May 9, 2008

Declaring Attribute Class In .Net

Adding a attribute class in .net is very simple.It's just a class declaration which inherits System.Attribute and is marked with AttributeUsage attribute.

[AttributeUsage(AttributeTargets.All)]
class MyAttributeClass : System.Attribute
{
//variables
//methods
}

once you declare this class you can use this as attribute in another class like following one


Class MySampleClass
{
[MyAttributeClass]
public void Dosomething()
{

}
}
More to come later...........

No comments:

Post a Comment