C#之特性
自定义自己的特性方法 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"; } }

浙公网安备 33010602011771号