1

Possible Duplicate:
How can I evaluate a C# expression dynamically?

I have one string in csharp

string li_id = "Frm_menu_purchase_order.visible=false;";

Now i wanna execute this string value as a c sharp statement

just like

Frm_menu_purchase_order.visible=false;
Community
  • 1
  • 1
pallavisahane
  • 59
  • 2
  • 9
  • this can be usefull.. or may be not http://stackoverflow.com/questions/508213/is-there-a-way-to-dynamically-execute-a-string-in-net-similar-to-eval-in-jav – Shekhar_Pro Jan 19 '12 at 12:21

3 Answers3

1

Description

You can use the Evaluator class found on Codeproject.

Check out Evaluate C# Code (Eval Function)

The class uses CodeDom do make this possible. But i suggest you are looking for another solution instead of using the Evaluator. But it works!

More Information

Community
  • 1
  • 1
dknaack
  • 60,192
  • 27
  • 155
  • 202
0

Use Reflection, please see below:

http://www.codeproject.com/KB/cs/evalcscode.aspx

Saurabh
  • 5,661
  • 2
  • 26
  • 32
0

You can use the CodeDom: http://www.codeproject.com/KB/dotnet/CodeDomDelegates.aspx

Strillo
  • 2,952
  • 13
  • 15