Click here to Skip to main content
15,882,388 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 11:54am

Try reflection...


The rest is just MSDN...
Share this answer
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 :)
Share this answer

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