-6

Let's say for example there are two textboxes: in one textbox the user enters "5", then on the second textbox the user enters 5 numbers "1 2 3 4 5" the computer has to add those 5 numbers from the textbox two together and display them.

How can I achieve this?

nvoigt
  • 75,013
  • 26
  • 93
  • 142
  • This is pretty easy next time listen in class. Also I'm pretty sure that you will not understand the given answer. – mybirthname Feb 21 '15 at 09:22

1 Answers1

2

The easiest way would probably be:

var numbersText = yourTextBox2.Text;

var allNumbersAddedUp = numbersText.Split(' ').Select(int.Parse).Sum();

Don't forget

using System.Linq;

This is independent of what the user enters in the first textbox.

As this seems to be a textbook homework, please do your own homework, read your textbooks and learn this by yourself instead of using ready-made solutions from the internet. One day I will have to work with you and I want to work with people who learned this instead of copied it from somewhere on the internet.

nvoigt
  • 75,013
  • 26
  • 93
  • 142