Accessing member using literal name

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is it possible if i have
class x {
object a1;
object b2;
object c3;
string names[] = {"a1", "b2", "c3"};
}
to iterate through the class members via Reflection or some other sort of
the current class, not just an instance of the class and acess these members
and manipulate their properties using their literal names i.e.
someMagicMethod.getMember(names[0]).mem = "4";
instead of
a1.mem = "1";
Thank you,
Josh
 
Yes, I've already looked at that:
Type myType = typeof(MyClass);
MemberInfo myMemInfo = myType.getMethod("MyFunc",
...etc.

Which gets me a method and I could create method accessors for all the
object I want, but the problem is that it is still not able to get the
current instance that I'm actually working in.

bruce barker (sqlwork.com) said:
yes, look at getmethod and invokemethod

-- bruce (sqlwork.com)


JoshZ said:
Is it possible if i have
class x {
object a1;
object b2;
object c3;
string names[] = {"a1", "b2", "c3"};
}
to iterate through the class members via Reflection or some other sort of
the current class, not just an instance of the class and acess these
members
and manipulate their properties using their literal names i.e.
someMagicMethod.getMember(names[0]).mem = "4";
instead of
a1.mem = "1";
Thank you,
Josh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top