2 using System.Reflection;
\r
4 [AttributeUsage(AttributeTargets.Field, AllowMultiple=false)]
\r
5 class SomeCustomAttribute : Attribute {
\r
6 public SomeCustomAttribute ()
\r
13 [SomeCustomAttribute]
\r
16 [SomeCustomAttribute]
\r
19 public static int Main ()
\r
21 Type t = typeof (MainClass);
\r
22 FieldInfo[] fia = t.GetFields();
\r
24 foreach (FieldInfo fi in fia) {
\r
25 object[] ca = fi.GetCustomAttributes(typeof (SomeCustomAttribute), false);
\r
26 System.Console.WriteLine ("Field: {0} [{1}]", fi.Name, ca.Length);
\r
31 Console.WriteLine ("OK");
\r