2 using System
.Reflection
;
4 [AttributeUsage(AttributeTargets
.Field
)]
5 public class AccessibleAttribute
:Attribute
{}
10 public const int MyConst
= 1;
16 public static int Main()
18 FieldInfo fieldInfo
= typeof(MyClass
).GetField("MyConst",
19 BindingFlags
.Static
| BindingFlags
.Public
);
21 AccessibleAttribute
[] attributes
=
22 fieldInfo
.GetCustomAttributes(
23 typeof(AccessibleAttribute
), true) as AccessibleAttribute
[];
25 if (attributes
!= null)
27 Console
.WriteLine ("Succeeded");