Calculator on C# | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Calculator on C#

Hi there, I just started C# and finished 'Conditionals and Loops' module. So, I wrote a basic calculator, which can add only 2 number: https://imgur.com/a/uZcDMRs Here is my question: how to write code that adds an infinite number of numbers?

1st Jun 2019, 11:17 AM
maksonios
maksonios - avatar
3 Answers
0
You want it to be like this? 1 + 1 = 2 2 + 2 = 4 3 + 3 = 6 ...
1st Jun 2019, 11:31 AM
Trigger
Trigger - avatar
0
I want to it be: 2+_ 2+5_ 2+5+7_ ... add a lot of numbers and place = where I want
1st Jun 2019, 11:33 AM
maksonios
maksonios - avatar
0
In Python you would use an eval() method. Though in C# they dont have a method like that (as far as I know) Luckily it's pretty easy to create one using the Compute method in the DataTable class😁 Here is an example, type in any sum that you want (addition, subtraction, multiplication etc.) https://code.sololearn.com/cpIvP3b6KYxU/?ref=app
1st Jun 2019, 11:42 AM
Trigger
Trigger - avatar