Get value of a public static field via reflection
You need to pass null
to GetValue
, since this field doesn't belong to any instance:
fields[0].GetValue(null)
You need to use Type.GetField(System.Reflection.BindingFlags) overload:
- http://msdn.microsoft.com/en-us/library/4ek9c21e.aspx
For example:
FieldInfo field = typeof(Settings.Lookup).GetField("Lookup", BindingFlags.Public | BindingFlags.Static);
Settings.Lookup lookup = (Settings.Lookup)field.GetValue(null);