Attributes:

  • Attributes are used to add metadata or declarative information to your code.
  • They provide a way to associate additional information or behavior with types, methods, properties, and other program elements.
  • Attributes can be used for code analysis, documentation generation, serialization, and more.

Example:

[Serializable]

[Obsolete(“This class is deprecated.”)]

public class MyClass

{

    // Class implementation

}