How to get property or class member variable value using reflection?

object obj;

 

PropertyInfo pi = obj.GetType().GetProperty("VariableName");

 

YourType value = (YourType)(pi.GetValue(obj, null));


Monday, January 21, 2008 | Comments (3) | Add Comment

Comments

Gravatar

Re:How to get property or class member variable value using reflection?

I need to access a public member of a class using reflection. And then call a method of that member (the member is an instance of another class)

11/3/2008 12:38:13 PM | by Nela
Gravatar

Re:How to get property or class member variable value using reflection?

No comment

11/13/2008 10:01:19 PM | by uday
Gravatar

Re:How to get property or class member variable value using reflection?

I've been looking for the past 2 days for this. Thank you !!!!!

11/30/2008 7:06:14 AM | by Dennis B

New Comment

Your Name:
Email (for internal use only):
Subject:
Comment:
 
Code above: