public static int[] RandomArray() { Random ran = new Random(); int[] arr = new int[10]; int tem; for (int i = 0; i < 10; i++) { tem = ran.Next(100, 1000); arr[i] = tem; } return arr; } private void Form1_Click(object sender, EventArgs e) { //mao pao sort int[] array = RandomArray(); for (int a = 0; a <= array.Length; a++) { int temp = 0; for (int b = array.Length - 1; b > a; b--) { if (array[b] < array[b - 1]) { temp = array[b]; array[b] = array[b - 1]; array[b - 1] = temp; } } } //print the data for (int i = 0; i < array.Length - 1; i++) { Console.WriteLine(array[i]); } }