what is the importance of attributes

seco

Well-known member
Joined
Mar 4, 2007
Messages
66
Programming Experience
Beginner
hi

what is the importance of built-in attributes and making attributes myself in my application

please i need real life sample shows that attributes help me in better coding or performance or what ever

thanks in advance.
 
Mmmm, i don't know that attributes will result in better code, or even faster code though in some situations applying the correct attributes could result in faster code execution. But really they are just information to the compiler know that an action is exptected before this method or class or even project is executed. I suppose they could be distantly related to Pre-Processor directives in c or c++. A real world example of the use of an attribute could be...

VB.NET:
<ToolBoxItem(False)> _
Public class SomeClass..


The above attribute would obivously prevent that class from showing up in the toolbox. Most of them are quite friendly in regard to how they have been named and so they're usage should be fairly clear.
You should create your own attribute if there are none that fit your purpose and you wish a custom action to be performed at runtime.
Here's an article that may help.

http://www.codeproject.com/csharp/dotnetattributes.asp
 
Back
Top