int[,] arr = new int[15, 20]; private void button1_Click(object sender, EventArgs e) { Random randomGenerator = new Random(); for (int i = 0; i<15; i++) { for (int j = 0; j<20; j++) { int TextNum = randomGenerator.Next((int)numericUpDown1.Value, (int)numericUpDown2.Value); arr[i, j] = TextNum; TextBox textBox = new TextBox() { Text = TextNum.ToString(), Location = new Point(40 + 105 * i, 40 + 30 * j), Width = 100, Height = 25, }; Controls.Add(textBox); } } for (int i=0; i<15; i++) { for (int j = 0; j < 20; j++) { Console.WriteLine(arr[i, j]); } } }