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