- int[] array = new int[10];
- Random rand = new Random();
- List<int> list = new List<int>();
- for (int i = 0; i < 5; i++)
- {
- //list[i] = rand.Next(1, 10);
- list.Add ( rand.Next(1, 11));
- }
- array = list.ToArray();
- Array.Sort(array);
- foreach (int i in array)
- {
- Console.WriteLine(i);
- }
- Console.ReadKey();
- }
- }
- }
复制代码 |