Attributes & Custom Annotations

Advanced

🏷️ 7. Attributes and Metadata-Driven Code

🔹 Using Built-in Attributes

[Obsolete("Use NewMethod instead")]
public void OldMethod() {}

🔹 Creating Custom Attributes

[AttributeUsage(AttributeTargets.Class)]
public class AuthorAttribute : Attribute
{
    public string Name { get; }
    public AuthorAttribute(string name) => Name = name;
}