C
C#2y 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
Thinker2y ago
How advanced do you want it to be? And how much work are you willing to put into it?
Norvik
NorvikOP2y ago
It must not be advanced. My current usage is as simple as "10+10-10*10/10"
Thinker
Thinker2y ago
I mean how advanced do you want your code which does this to be?
Norvik
NorvikOP2y ago
Not advanced
mtreit
mtreit2y 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
Thinker2y ago
Then the easiest solution would probably just be to use a pre-made library
Norvik
NorvikOP2y ago
I will check out the Github. Thank you, you both
Want results from more Discord servers?
Add your server