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 {
35 [My2("testclass", 22)]
36 [My3(Prop = new char [] { 'A', 'B', 'C' })]
38 static public int Main() {
39 System.Reflection.MemberInfo info = typeof (Test);
40 object[] attributes = info.GetCustomAttributes (false);
41 for (int i = 0; i < attributes.Length; i ++) {
42 System.Console.WriteLine(attributes[i]);
44 if (attributes.Length != 3)
46 for (int i = 0; i < attributes.Length; ++i) {
47 if (attributes [i] is MyAttribute) {
48 if (((MyAttribute)attributes [i]).val != "testclass")
51 if (attributes [i] is My3Attribute) {
52 if (new String (((My3Attribute)attributes [i]).Prop) != "ABC")