How do I dynamically reference incremented properties in C#?

Posted by Jeff Blankenburg on Stack Overflow See other posts from Stack Overflow or by Jeff Blankenburg
Published on 2010-04-12T15:37:42Z Indexed on 2010/04/12 15:43 UTC
Read the original article Hit count: 253

Filed under:
|
|
|

I have properties called reel1, reel2, reel3, and reel4. How can I dynamically reference these properties by just passing an integer (1-4) to my method?

Specifically, I am looking for how to get an object reference without knowing the name of the object.

In Javascript, I would do:

temp = eval("reel" + tempInt);

and temp would be equal to reel1, the object.

Can't seem to figure this simple concept out in C#.

© Stack Overflow or respective owner

Related posts about c#

Related posts about JavaScript