Yes, it can be done.
Used by Type.GetProperty() .
Example:
// Load your assembly and Get the Type // Assembly load code... ... // Get type Type asmType = typeof(C); // Get internal properties PropertyInfo pi = asmType.GetProperty("About_Name", BindingFlags.NonPublic | BindingFlags.Static); // Get Value var val = pi.GetValue(asmType, null);
This code will return " text " to val , so from there do what you need with it.
To do this in the sense in which you want, enter the code into the method as follows:
private static string GetString(Type classToCheck, string PropertyName) { PropertyInfo pi = classToCheck.GetProperty(PropertyName, BindingFlags.NonPublic | BindingFlags.Static); object val = null; if (pi != null) val = pi.GetValue(classToCheck, null); return (val != null) ? val.ToString() : string.Empty; }
Then use will be:
string expected = GetString(typeof(C), "About_Name");
source share