Example

 using System; using System.Reflection; namespace Samples { [AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = true)] public class AuthorAttribute: Attribute { private string familyName; private string givenName; public AuthorAttribute(string familyName) { this.familyName = familyName; } public override String ToString() { return String.Format("Author: {0} {1}", familyName, givenName); } public string FamilyName { get {return familyName;} } public string GivenName { get {return givenName;} set {givenName = value;} } } [Author("Watkins", GivenName = "Damien")] [Author("Abrams")] public class AttributeSample { [Author("Abrams", GivenName = "Brad")] public static void Main() { Type t = typeof(AttributeSample); Attribute[] ...

Get .NET Framework Standard Library Annotated Reference, Volume 1: Base Class Library and Extended Numerics Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.