What is the purpose of Attributes in C#?

Viewed 6247
  • What is the purpose of Attributes in C#?

  • How do I know which attribute have to use for particular functionality?

  • How can I add them dynamically in c#?

  • What are custom attributes ?

8 Answers

Attributes are often used when setting different environment such as DEBUG, DEV, STAGING, PROD, Etc.

  [Conditional("DEBUG")]
        private void OutputDebugInfo()
        {
            WriteLine("***DEBUG MODE ***");
        }
Related