Otex
February 20th, 2009, 02:54 AM
Hi,
I am not sure how to explain this, I'd like to have some code dynamically created at execution in my program.
Maybe if I put some non working code it would give a better idea
int a = 1;
int b = 2;
string myLogic = "a + b";
int c = myMethod(myLogic);
// c would be 3
// of course if myLogic was "a * b", c would be 2 etc..
public int myMethod(string logic)
{
int result;
..
..
..
return (result);
}
In other words I'd like to convert my string to code.
I suspect maybe invokemember or delegates may help me but I cant work it out.
Any help appreciated
I am not sure how to explain this, I'd like to have some code dynamically created at execution in my program.
Maybe if I put some non working code it would give a better idea
int a = 1;
int b = 2;
string myLogic = "a + b";
int c = myMethod(myLogic);
// c would be 3
// of course if myLogic was "a * b", c would be 2 etc..
public int myMethod(string logic)
{
int result;
..
..
..
return (result);
}
In other words I'd like to convert my string to code.
I suspect maybe invokemember or delegates may help me but I cant work it out.
Any help appreciated