Click here to Skip to main content
16,004,564 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
What is Advantages and Uses of Attribute in c# ?
Create and Implement of Custom Attribute ?
Check a String with help of attribute in Console Application in c#
Posted
Comments
Philippe Mori 16-Aug-11 19:35pm    
Last question is not clear.

The uses of attributes varies. But in general it's used in combination with reflection.

For example DisplayNameAttribute, DiscriptionAttribute, CategoryAttribute and DefaultValueAttribute are used by Visual Studio to populate the property pane when using the winforms/wpf designer.

All the aspect-oriented frameworks I know of uses attributes to indicate which aspect is to be applied to which class, method or property.

You implement your own attribute by inheriting from the class Attribute and use it like any other attribute.
C#
[MyAttribute]
public class MyClass { }
 
Share this answer
 
Comments
[no name] 16-Aug-11 16:10pm    
+5
 
Share this answer
 
Comments
Sander Rossel 16-Aug-11 13:27pm    
I handed in your answer to my teacher, and failed the Class! I only had one potato and a bread too!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900