How to get the value of a private static field from a class?
问题 Is there any way to get value of private static field from known class using reflection? 回答1: Yes. Type type = typeof(TheClass); FieldInfo info = type.GetField(name, BindingFlags.NonPublic | BindingFlags.Static); object value = info.GetValue(null); This is for a field. For a property, change type.GetField to type.GetProperty . You can also access private methods in a similar fashion. 回答2: I suppose someone should ask whether this is a good idea or not? It creates a dependency on the private