Andy Sujoto

Andy Sujoto

  • NA
  • 8
  • 19.7k

c# Eval() or compile on fly with object

Aug 19 2010 6:30 AM
Hi,

I have tried using CodeDomProvider to compile the code on fly and get the value returned, like :
string sEval = "1+1", will always return 2.

However when i try to use the same concept on object like example below, i got an error  :

I have a webform with 3 textbox on it, named Label1, Label2, Label3.

Label1.Text = "my first name"
Label2.Text = " my family name"

string sEval = "Label3.Text = Label1.Text + Label2.Text"
now i want to run sEval that will fill Label3.Text = "my first name, my family name".

how to achieve that? please help.

Thanks in advance,
Andy


Answers (5)