I have a list containing user entered values. I would like all integers entered to sum together at the end and the total to be displayed. Is this possible?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BubbleSort1
{
class Program
{
static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.Green;
List<int> price= new List<int>();
enterprice:
Console.WriteLine("Please enter price");
Console.WriteLine("When Finished please press '/'");
string pricex = Console.ReadLine();
if (pricex == "/")
{
goto receipt;
}
else
{
int pricey = Convert.ToInt16(pricex);
price.Add(pricey);
Console.Clear();
goto enterprice;
}
receipt:
Console.Clear();
Console.WriteLine("Your Outflows:");
Console.WriteLine(string.Join("\n", price));
Console.ReadKey();
}
}
}
Before anyone mentions I understand there are better methods than goto and I could probably save user entered data straight as integers and I will learn how but have just started so want to take my time with it. Many thanks ;)