Beispiel #1
0
        public Stores()
        {
            stores = new Prices[2];

            for (int i = 0; i < stores.Length; i++)
            {
                string name;
                Console.WriteLine("Enter store: ");
                name = Console.ReadLine();

                string prod;
                Console.WriteLine("Enter product: ");
                prod = Console.ReadLine();

                double?price;
                Console.WriteLine("Enter price: ");
                try
                {
                    price = Convert.ToDouble(Console.ReadLine());
                }
                catch (Exception e)
                {
                    Console.WriteLine("Wrong price!");
                    Console.WriteLine(e.Message);
                    price = null;
                }
                stores[i] = new Prices(name, prod, price);
            }
            stores = stores.OrderBy(products => products.StoreName).ToArray <Prices>();
        }
Beispiel #2
0
 public string Show(Prices a)
 {
     return(a.ProductName + ": " + a.Price);
 }