Click here to Skip to main content
13,150,472 members (34,376 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I'm trying to create a program that can accept infinite inputs and add them up. The input will be put in a text-box and submitted with a button. Any suggestions?
Posted 14-Oct-12 6:51am
Wes Aday 14-Oct-12 13:02pm
Get input, add to total, get input, add to total, repeat infinitely.
Curtdawg123 14-Oct-12 13:21pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

//u need to add  System.Text.RegularExpressions;
//Input is ur input string
string[] Numbers = Regex.Split(Input, @"\D+");
int Temp=0,Sum=0;
foreach(string i in Numbers)
if(int.TryParse(i,out Temp))
Sum += Temp;

Above code will take only Numbers.
Skips all Non-Digit characters, so to separate any number use any Non-Digit character
Maciej Los 14-Oct-12 15:36pm
Good job, +5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170924.2 | Last Updated 14 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100