C# eval equivalent?

Posted by Adhip Gupta on Stack Overflow See other posts from Stack Overflow or by Adhip Gupta
Published on 2008-08-07T12:26:46Z Indexed on 2010/06/09 4:42 UTC
Read the original article Hit count: 163

Filed under:
|
|

I can do an eval("something()"); to execute the code dynamically in JavaScript. Is there a way for me to do the same thing in C#?

What I am exactly trying to do is that I have an integer variable (say i) and I have multiple properties by the names: "Property1","Property2","Property3" etc. Now, I want to perform some operations on the " Propertyi " property depending on the value of i.

This is really simple with Javascript. Is there any way to do this with C#?

Edit: Oh, and I am using C# 2.0

© Stack Overflow or respective owner

Related posts about c#

Related posts about reflection