3 using System.Reflection;
6 public class MyAttribute: Attribute {
8 public MyAttribute (string stuff) {
9 System.Console.WriteLine (stuff);
13 public class My2Attribute: MyAttribute {
15 public My2Attribute (string stuff, int blah) : base (stuff) {
16 System.Console.WriteLine ("ctor with int val"+stuff);
21 public class My3Attribute : Attribute {
37 [My2("testclass", 22)]
38 [My3(Prop = new char [] { 'A', 'B', 'C', 'D' }, Prop2 = new char [] { 'A', 'D' })]
40 static public int Main() {
41 System.Reflection.MemberInfo info = typeof (Test);
42 object[] attributes = info.GetCustomAttributes (false);
43 for (int i = 0; i < attributes.Length; i ++) {
44 System.Console.WriteLine(attributes[i]);
46 if (attributes.Length != 3)
48 for (int i = 0; i < attributes.Length; ++i) {
49 if (attributes [i] is MyAttribute) {
50 if (((MyAttribute)attributes [i]).val != "testclass")
53 if (attributes [i] is My3Attribute) {
54 if (new String (((My3Attribute)attributes [i]).Prop) != "ABCD") {
55 Console.WriteLine (new String (((My3Attribute)attributes [i]).Prop));
58 if (new String (((My3Attribute)attributes [i]).Prop2) != "AD") {
59 Console.WriteLine (new String (((My3Attribute)attributes [i]).Prop2));