Click here to Skip to main content
15,171,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,
I have a class say,
class a
public int  b;
public int  c;
public int d;

I want to iterate through the members and store values in b , c ... d
Is it possible. Can you suggest a good way of doing this.
Best Regards
Updated 24-Feb-12 12:54pm

Try reflection...


The rest is just MSDN...
J imran 24-Feb-12 17:52pm
the getproperties work for static members. I am trying to address the members of instance of a
voloda2 24-Feb-12 17:53pm
it works for both. if you want dynamic behavior just use:
a myVar;
J imran 24-Feb-12 17:57pm
thank you friend. So nice...
it means I can crack to any liberary to get private members even.
Seems Confusing. Is it possible that I get to the private members also and get their values changed. If so It will work great
It looks like you want to access Fields of a type and set value to it. Please have a look into,


Hope it helps :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900