public static void ParseInput() { var invoiceMap = new Dictionary <string, bool>(); invoices = new List <Invoice>(); while (true) { var input = Console.ReadLine(); if (input.Equals("End")) { return; } var parse = input.Split(','); if (invoiceMap.ContainsKey(parse[3])) { var invoiceList = invoices.Where(invoice => invoice.GetId().Equals(parse[3])); invoiceList.First().AddParts(parse[1], parse[2], parse[5], Int32.Parse(parse[6])); Console.WriteLine(Int32.Parse(parse[6]).ToString()); } else { var newInvoice = new Invoice(parse[3], Int32.Parse(parse[4])); newInvoice.AddParts(parse[1], parse[2], parse[5], Int32.Parse(parse[6])); invoiceMap[newInvoice.GetId()] = true; invoices.Add(newInvoice); } } }