Custom attribute information

xiaoxiao2021-03-06  42

Namespace programming_cshar {using system; using system.reflection;

// Declaration Property / / The first parameter is a set of indicates that the target of the target // second parameter represents whether the number can accept one or more attribute information [AttributeTargets.class | AttributeTargets.field | AttributeTargets.field | AttributeTargets.Method | AttributeTargets.Property, ALLOWMULTIPLE = true)] public class bugfixattribute: system.attribute {// attribute information There are two parameters: position and naming parameter // position parameters will pass into the constructor, and must The order in which the declaration declared in the constructor; // naming parameters are implemented in nature // [bugfixattribute (107, "Jesse Liberty", "03/04/05", comment = "fixed off one error")] // The above Comment is a named parameter, the rest of the position-type public bugfixattribute (int bugid, string programmer, string date) {this.bugid = bugid; this.programmer = programmer; this.date = date;} public int buj {GET {return bugid;}}} {comment = value;}} public string date;}} public string Date;}} public string program;}} public string program; Return Programmer;} set {programer = value;}} private; private string commerss ATE STRING DATE; Private String Programmer;}

[BugfixaTribute (121, "Jesse Liberty", "04/05/06")] [Bugfixattribute (107, "Jesse Liberty", "03/04/05", Comment = "Fixed Off By Orge")] Public Class MyMath {public double DoFunc1 (double param1) {return param1 DoFunc2 (param1);} public double DoFunc2 (double param1) {return param1 / 3;}} public class Tester {public static void Main () {MyMath mm = new MyMath (); Console.writeline ("Calling Dofunc1 (7). Result: {0}", mm.dofunc1 (7));

转载请注明原文地址:https://www.9cbs.com/read-68719.html

New Post(0)