C# 自定义特性

 1  [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = false)]
 2     public class LastModifiedAttribute : Attribute
 3     {
 4         private readonly DateTime _dateModified { get; private set; }
 5         private readonly string _changes { get; private set; }
 6         public LastModifiedAttribute(string dateModified, string changes)
 7         {
 8             _dateModified = DateTime.Parse(dateModified);
 9             _changes = changes;
10         }
11         public string Issues { get; set; }
12     }
13 
14     [AttributeUsage(AttributeTargets.Assembly)]
15     public class SupportsWhatsNewAttribute : Attribute
16     { }
原文地址:https://www.cnblogs.com/farmer-y/p/5984368.html