Error entering data from the keyboard.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SimpleClassConlsole { class Program { static void Main(string[] args) { ReadProductsArray(); Console.ReadKey(); } public static int n { get; private set; } public static Product[] products = new Product[n]; public static Product[] Products { set; get; } public static void ReadProductsArray() { Console.WriteLine("Введіть кількість товарів:"); if (!byte.TryParse(Console.ReadLine(), out byte n)) { Console.WriteLine("Помилка введення значення. Будь-ласка повторіть введення значення ще раз!"); } for (int i = 0; i < n; i++) { Console.WriteLine($"----------------{i}---------------"); Console.WriteLine("Введіть ім'я:"); products[i].Name = Console.ReadLine(); Console.WriteLine("Введіть ціну:"); products[i].Price = Convert.ToSingle(Console.ReadLine()); Console.WriteLine("Введіть кількість:"); products[i].Quantity = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Введіть виробника:"); products[i].Producer = Console.ReadLine(); Console.WriteLine("Введіть вагу:"); products[i].Weight = Convert.ToSingle(Console.ReadLine()); } } public static void PrintProducts(Product[] products) { for (int i = 0; i < n; i++) { Console.WriteLine($"------------------------------------\n" + $"Товар #{i}: {products[i].Name}\n Ціна: {products[i].Price}\n " + $"Кількість: {products[i].Quantity}\n Виробник: {products[i].Producer}\n " + $"Вага: {products[i].Weight}\n"); } } public static void PrintProduct(Product product) { Console.WriteLine($"------------------------------------\n" + $"Товар #: {product.Name}\n Ціна: {product.Price}\n " + $"Кількість: {product.Quantity}\n Виробник: {product.Producer}\n " + $"Вага: {product.Weight}\n"); } public static void GetProductsInfo(out Product lower, out Product high) { high = products[0]; lower = products[0]; float lowCost = products[0].Price, hightCost = products[0].Price; for (int i = 0; i < n; i++) { if (products[i].Price > hightCost) { hightCost = products[i].Price; high = products[i]; } if (products[i].Price < lowCost) { lowCost = products[i].Price; lower = products[i]; } } } } } 