C#
T-SQL
ASP.NET
Javascript
WPF
CSS
FLEX
LINQ
object obj;
PropertyInfo pi = obj.GetType().GetProperty("VariableName");
YourType value = (YourType)(pi.GetValue(obj, null));
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)
No comment
I've been looking for the past 2 days for this. Thank you !!!!!
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);}
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);}