Hello, the application on winforms, which will be "simulated" banking queue. An array of queues Queue<int>[] QArray , the number of queues is sent from the textbox, then numbers are written to each of the queues, the number of clients in the queue is output to the labels.
M = int.Parse(textBox1.Text); //Количество очередей QArray = new Queue<int>[M]; int element = 0; for(int i=0;i< M; i++) { Random rnd = new Random(); int m = rnd.Next(1, 8);//Количество элементов в очереди for (int j = 0; j <m; j++) { element = rnd.Next(3, 30); QArray[i].Enqueue(element); // ОШИБКА } } for (int i=0;i< M; i++) { var labelnumber = i; var label = new Label(); { Location = new Point(46, 132 + i * 15); Text = QArray[M].Count.ToString() ; } this.Controls.Add(label); } After entering the value in the textbox, the exception appears “Object reference does not indicate an object instance.” Tell me what the problem is, please.
var label = new Label();- transfer ";" in after "}".QArray[M]- index out of bounds. - Igor