Advertisement

12.06.2007 at 02:17PM PST, ID: 23007393
[x]
Attachment Details

Reflection question

Asked by joebednarz in C# Programming Language, .NET

Tags: Microsoft, Visual Studio, 2008, c#

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
[+][-]12.06.2007 at 02:45PM PST, ID: 20424130

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: C# Programming Language, .NET
Tags: Microsoft, Visual Studio, 2008, c#
Sign Up Now!
Solution Provided By: surajguptha
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628