static void Main(string[] args) { int[] num = new int[100]; ArrayList Mylist = new ArrayList(); Random rd = new Random(); while (Mylist.Count < 100) { int i=rd.Next(1, 101); if (!Mylist.Contains(i)) Mylist.Add(i); } for (int i = 0; i < num.Length; i++) { num[i] = (int)Mylist[i]; } for (int j = 0; j < num.Length - 1; j++) { for (int i = 0; i < num.Length - 1 - j; i++) { if (num[i] > num[i + 1]) { int temp = num[i]; num[i] = num[i + 1]; num[i + 1] = temp; } } } foreach (var i in num) { Console.WriteLine(i); } Console.ReadKey(); }