It appears that this will test for a const field:
Introspection:
public override ProblemCollection Check(Member member)
{
Field field = member as Field;
if ((field != null) && field.IsLiteral)
{
// Do something... the field is a const
}
return base.Check(member);
}
Reflection:
Look at FieldInfo.IsLiteral
"James Geurts" wrote:
Hi,
Can someone tell me how to test if a field is a const? I am using the FxCop
introspection engine, but I suppose I could use reflection if required.
for example, the following would return true:
private const string DEFAULT_STRING = "Default";
thanks
Jim