I'm trying to write some code using Reflection, that will return the value of a public constant in a different class. I'm pretty new to C# programming (as well as Reflection!) and I just can't seem to get it right. I bet there are examples out there on Google, but I imagine I'm not putting in the right words to search...
Here is a snippet:
(class code)
namespace Address
public static string targetString = "xyz";
// other methods, etc.
(reflection code)
public void test()
{
Type t = typeof( Address );
PropertyInfo[] pInfo = t.GetProperties();
// other code, which is obviously not correct...
Anyway, what I'm trying to do in my "test" procedure is find the value of "targetString"... seems simple enough to me in concept, but it just isn't working!!!! Any ideas?
Start Free Trial