C
C#3y ago
Norvik

String to math

I have a string " 10 + 10 + 10 " and want to calculate it. How can I do that?
7 Replies
Thinker
Thinker3y ago
How advanced do you want it to be? And how much work are you willing to put into it?
Norvik
NorvikOP3y ago
It must not be advanced. My current usage is as simple as "10+10-10*10/10"
Thinker
Thinker3y ago
I mean how advanced do you want your code which does this to be?
Norvik
NorvikOP3y ago
Not advanced
mtreit
mtreit3y ago
There are existing projects for this kind of thing. For example: https://github.com/codingseb/ExpressionEvaluator
GitHub
GitHub - codingseb/ExpressionEvaluator: A Simple Math and Pseudo C#...
A Simple Math and Pseudo C# Expression Evaluator in One C# File. Can also execute small C# like scripts - GitHub - codingseb/ExpressionEvaluator: A Simple Math and Pseudo C# Expression Evaluator in...
Thinker
Thinker3y ago
Then the easiest solution would probably just be to use a pre-made library
Norvik
NorvikOP3y ago
I will check out the Github. Thank you, you both

Did you find this page helpful?