attributes_quiz.md - brainchildservices/curriculum GitHub Wiki

  1. What is Attributes ?

    Attributes are like adjectives, which are used for metadata annotation that can be applied to a given type, assembly, module, method and so on. The .NET framework stipulates two types of attribute implementations, which are Predefined Attributes and Custom Attributes.

  2. Uses of Attributes ?

    Attributes might be useful for documentation purposes. They fulfill many roles, including describing serialization, indicating conditional compilation, specifying import linkage and setting class blueprint and so on. Attributes allow information to be defined and applied to nearly any metadata table entry. This extensible metadata information can be queried at run time to dynamically alter the way code executes.

  3. What is Attribute specification ?

    Attribute specification is the application of a previously defined attribute to a declaration. An attribute is a piece of additional declarative information that is specified for a declaration.

  4. What is Attribute instances ?

    An attribute instance is an instance that represents an attribute at run-time. An attribute is defined with an attribute class, positional arguments, and named arguments. An attribute instance is an instance of the attribute class that is initialized with the positional and named arguments.

  5. What is Reserved Attributes ?

    Attributes are used to append declarative information to your programs. This information is interpreted during execution and appropriate action is taken. C# provides ready-to-use attributes called reserved attributes.

  6. List 3 Reserved Attributes

    • AttributeUsage
    • Conditional
    • Obsolete
  7. List AttributeUsage

    • validation: Defines which all program entities can use this attribute
    • AllowMultiple: When this parameter is set to true, multiple values can be set to the attribute when it is associated with an entity
    • Inherited: When it is set to true, derived classes can inherit the attributes used in the base class
  8. Define Conditional Attributes ?

    Conditional attribute can be applied on a method belonging to a class or struct. This attribute determines whether the method (to which it is associated) has to be executed based on the compilation symbol associated with this attribute.

⚠️ **GitHub.com Fallback** ⚠️