自定义自己的特性方法 MyCustom
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Field | AttributeTargets.Method, Inherited = true, AllowMultiple = true)] public sealed class MyCustomAttribute : Attribute { public MyCustomAttribute() { } public MyCustomAttribute(string name) { } }
关于 MyCustom 使用
[Serializable()] public class AttributeExam { [MyCustom()] public int Index; [MyCustom()] public string Name; [MyCustom("name")] public void Run() { } [MyCustom("name")] public string Say() { return "MyCustom"; } }
标签:MyCustom,string,C#,AttributeTargets,特性,MyCustomAttribute,public,name From: https://www.cnblogs.com/ehuanrum/p/6627122.html