Hi all,

Firstly, I apologise if I am threading old water here - I had a brief search but could not find what I was looking for....

I want to know if it is possible to evaluate a text string as if it is actual code, e.g.

string equation = "";
for (int i = 1; i <= 2; i++)
equation += @"Convert.ToInt16(txtValue" + i.ToString() + @".Text) +";
equation += " 0";
lblEquals.Text = equation;

output string: "Convert.ToInt16(txtValue1.Text) + Convert.ToInt16(txtValue2.Text) + 0"

Basically, I want to evaluate the output string, as generated by the loop, as c# code as if I had just entered:

int16 value = Convert.ToInt16(txtValue1.Text) + Convert.ToInt16(txtValue2.Text) + 0;

I will not know, until run time, how many variables there are going to be but they will all be similar to txtValuen.Text

Is this possible or am I barking up the wrong tree?