Beispiel #1
0
        public static long Add(string csvText)
        {
            // Return 0 if the input is empty
            if (csvText == string.Empty)
            {
                return(0);
            }

            // Otherwise calculate the total if there are no negatives
            var strings = Csv.Read(csvText).GetIndividualElements();

            GetNegatives(strings);

            // sum of te numbers
            TOTAL = 0;
            foreach (var str in strings)
            {
                TOTAL += long.Parse(str);
            }

            return(TOTAL);
        }
Beispiel #2
0
 private static IEnumerable <long> TheIndividualElementsOfThe(string csvText)
 {
     return(Csv.Read(csvText).GetIndividualElements());
 }