Realtime complination in C# [duplicate]
Possible Duplicate:
Is there a method that will evaluate a string and produce an integer (assuming the string is an equation) in C#
Hi all, i just wonder how to make a realtime complination in C# For example: i have a string like this
string math = "1 + 2 + (4 - 6)";
And i want to complie it to get the result How to do that? and is that the bad idea because i want to make a calculator in C#?
Edited: The main question properly is that i want to do it in WP7, not exactly in C# windows lol, i tried all the solutions below but not at all is correct!
and is that the bad idea because i want to make a calculator in C#?
One problem with that is that your calculator language is probably supposed to be just a subset of C#. So using the C# compiler may be too flexible and allow arbitrary C#. Kind of like problems with SQL injection attacks.
Expresion Evalution is an application of STACK (Data Structure)
You can see these link If you want Sample projects
- http://www.vbforums.com/showthread.php?t=397264
- http://www.codeproject.com/KB/cs/runtime_eval.aspx
- http://www.c-sharpcorner.com/uploadfile/mgold/codedomcalculator08082005003253am/codedomcalculator.aspx
精彩评论