1 // cs-20.cs : Cannot find attribute type My (maybe you forgot to set the usage using the AttributeUsage attribute ?).
5 using System.Reflection;
9 //[AttributeUsage (AttributeTargets.All)]
10 public class MyAttribute: Attribute {
12 public MyAttribute (string stuff) {
13 System.Console.WriteLine (stuff);
21 static public int Main() {
22 System.Reflection.MemberInfo info = typeof (Test);
23 object[] attributes = info.GetCustomAttributes (false);
24 for (int i = 0; i < attributes.Length; i ++) {
25 System.Console.WriteLine(attributes[i]);
27 if (attributes.Length != 2)
29 MyAttribute attr = (MyAttribute) attributes [0];
30 if (attr.val != "testclass")