Home » C# .NET » How to get property or class member variable value using reflection? 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)); Posted on Monday, January 21, 2008 by Viktar Karpach | Comments (6) | Add Comment Comments 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) Posted on 11/3/2008 12:38:13 PM by Nela # Re:How to get property or class member variable value using reflection? No comment Posted on 11/13/2008 10:01:19 PM by uday # 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 !!!!! Posted on 11/30/2008 7:06:14 AM by Dennis B # Re:How to get property or class member variable value using reflection? namespace MyNamespace{ public class MyClass { public static string sName; public static string SName { get { return sName; } set { sName = value; } }}protected void btnAccessProperty_Click(object sender, EventArgs e) { MyNamespace.MyClass myCls = new MyNamespace.MyClass(); PropertyInfo pi = myCls.GetType().GetProperty("SName"); string value = (string)(pi.GetValue(null, null)); Response.Write(value);} Posted on 2/22/2010 11:00:08 PM by Anonymous # Re:How to get property or class member variable value using reflection? namespace MyNamespace{ public class MyClass { public static string sName; public static string SName { get { return sName; } set { sName = value; } }}protected void btnAccessProperty_Click(object sender, EventArgs e) { MyNamespace.MyClass .SName = "Sheetal"; MyNamespace.MyClass myCls = new MyNamespace.MyClass(); PropertyInfo pi = myCls.GetType().GetProperty("SName"); string value = (string)(pi.GetValue(null, null)); Response.Write(value);} Posted on 2/22/2010 11:02:33 PM by Anonymous # Re:How to get property or class member variable value using reflection? namespace MyNamespace{public class MyClass{public static string sName;public static string SName{get { return sName; }set { sName = value; }}}protected void btnAccessProperty_Click(object sender, EventArgs e){MyNamespace.MyClass .SName = "Sheetal";MyNamespace.MyClass myCls = new MyNamespace.MyClass();PropertyInfo pi = myCls.GetType().GetProperty("SName");string value = (string)(pi.GetValue(myCls, null));Response.Write(value);} Posted on 4/18/2010 10:30:54 PM by Harpreet # New Comment Your Name: Email (for internal use only): Comment: Code above: