Using system;
Namespace consoleApplication2 {/// /// Class1 Summary Description. /// summary> class class1 {/// /// The primary entry point of the application. /// summary> [stathread] static void main (String [] args) {system.reflection.memberinfo info = typeof (myclass); // This thing is a feedback information about class Myattribute Att = (MyAttribute) Attribute .Getcustomattribute (INFO, TYPEOF (MyAttribute)); // This thing gets this attribute if (att! = Null) {Console.Writeline ("Myattribute.a: {0}", att.a); console .WriteLine ("MyAttribute.b: {0}", att.b);} // // Todo: Add code to start the application //}} [attributeusage (attributeTargets.class)] public class myattribute: Attribute {public int A; public string b; public myattribute (int A, string b) {this.a = a; this.b = b;}
}
[MyAttribute (5, "Hello Attribute World"] Public class myclass {}} The scope of metadata Attribute can make the class, or the function, as follows is the definition of the type of enumeration. Public enum attributetargets {all = 16383, assembly = 1, module = 2, class = 4, struct = 8, enum = 16, constructor = 32, method = 64, property = 128, field = 256, Event = 512, Interface = 1024, Parameter = 2048, DELEGATE = 4096, ReturnValue = 8192} This thing does have a little like adjective and adverb, some descriptions for their own information. interesting.