1

I have one scenario in C#, which I fetch the expression from database, I need to parse and evaluate the same

The expression can be of any type (With + & - Operator only) as mentioned below

X+Y-Z
X-Y-Z
Z-Y+Z

Where as at run time I have any of above expression as string item and the values for each variable defined in it.

Now I need to automate the same, so that my code at run time will able to parse and evaluate the same.

I believe Switch case and if/else loop is the one way, but any can please suggest some other better and efficient way.

Thanks in advance

Vsagar
  • 197
  • 2
  • 17
  • 1
    The irony in denying this type of duplicate question is that all the answers provided in the previous questions are ancient containing accepted answers with deprecated and / or abandoned solutions. It should be understood that searches can be filtered by date in an attempt to arrive at questions with answers relevant to recent code standards and the questions like these, albeit seemingly just duplicates, could provide relevancy. If nobody's asking the question since it's already been asked, who's providing the updated answers? – BJS3D Mar 22 '19 at 15:59
  • 1
    Since both the questions cited herein to prove this as a duplicate question are well over a decade old containing code responses and links that are every bit as antiquated, I would think that some sort of time limit being placed on such an assessment would be prudent. After all, .NET has changed considerably in the 11 years since the original questions were asked. The answers to this question would have been dramatically different and far more useful today. – BJS3D Mar 22 '19 at 16:04

0 Answers0