To see which instance of the static members you're currently executing
ToString
for requires you to get the value and then see if that is equal to
this
, something like this might do the trick;
public override string ToString()
{
FieldInfo[] fields = GetType().GetFields(BindingFlags.FlattenHierarchy | BindingFlags.Static | BindingFlags.Public);
foreach (FieldInfo field in fields)
{
object value = field.GetValue(this);
if (Object.ReferenceEquals(value, this))
return field.Name;
}
return base.ToString();
}
Hope this helps,
Fredrik