Attribute एक Declarative Tag है जिसका उपयोग आपके Program में Classes, Methods, Structures, Enumerators, Assemblies आदि जैसे विभिन्न Elements के Behaviors के बारे में Runtime को Information Convey करने के लिए किया जाता है।
निम्न Syntax है।
[attribute(positional_parameters, name_parameter = value, ...)] Element
यहां,
Attribute का Name और इसके Values Square Brackets के भीतर Specified होते हैं, उस Element से पहले जिस पर Attribute Apply किया जाता है।
Positional Parameters Essential Information Specify करते हैं और Name Parameters Optional Information Specify करते हैं।
C# में निम्न Predefined Attributes हैं।
AttributeUsage
Pre-defined Attribute AttributeUsage Describe करता है कि Custom Attribute Class का उपयोग कैसे किया जा सकता है।
Conditional
यह Predefined Attribute एक Conditional Method को Mark करता है जिसका Execution Specified Preprocessing Identifier पर Depend करता है।
Obsolete
Obsolete Predefined Attribute एक Program Entity को Mark करता है जिसका उपयोग नहीं किया जाना चाहिए। यह आपको Compiler को एक Particular Target Element को Discard करने के लिए Inform करने में सक्षम बनाता है।