static void Main(string[] args)
        {
            Console.WriteLine("Product");

            var           receipt  = new List <Bonregel>();
            string        actie    = null;
            List <string> products = new List <string>();

            while (actie != "x")
            {
                Console.WriteLine("Wat wil je doen: ");
                actie = Console.ReadLine();
                switch (actie)
                {
                case "p":
                {
                    Console.WriteLine("Geef product op:");
                    string product = Console.ReadLine();

                    Console.WriteLine("Geef bedrag op:");
                    int bedrag = Convert.ToInt32(Console.ReadLine());

                    var regel = new Bonregel();
                    regel.Bedrag  = bedrag;
                    regel.Product = product;
                    receipt.Add(regel);
                }
                break;

                case "d":
                {
                    Console.WriteLine();
                }
                break;

                case "s":
                {
                    var groupedProductList = receipt.GroupBy(item => item.Product);
                    foreach (var productregel in receipt)
                    {
                        Console.WriteLine("Product: " + productregel.Product);
                        Console.WriteLine("Bedrag: " + productregel.Bedrag);
                    }
                }
                break;

                case "x":
                {
                    StopApp stop = new StopApp();
                    var     quit = stop.Quit();
                }
                break;

                default:
                    Console.WriteLine("Ongeldige keuze!");
                    break;
                }
                Console.WriteLine("-------------------");
            }
        }
Exemple #2
0
    static void Main()
    {
        var    receipt = new List <Bonregel>();
        string product = null;
        int    bedrag;

        while (product != "x")
        {
            Console.WriteLine("Wat voor product: ");
            product = Console.ReadLine();

            if (product == "x")
            {
                Console.WriteLine("Stop");
            }
            else if (product == "som")
            {
                foreach (var regel in receipt)
                {
                    Console.WriteLine("{0} {1}", regel.Product, regel.Bedrag);
                }
            }
            else if (product == "export")
            {
                var exportregel = new Exportbon();

                exportregel.Exportbedrag = product;
                exportregel.Exportprod;
            }
            else
            {
                Console.WriteLine("Wat voor bedrag: ");
                bedrag = Convert.ToInt32(Console.ReadLine());
                var regel = new Bonregel();

                regel.Bedrag  = bedrag;
                regel.Product = product;
                receipt.Add(regel);
            }
        }
        Console.ReadLine();
    }