static void Main(string[] args) { int[] myNum = new int[100]; myNum = GetRand(1, 100, 100); Array.Sort(myNum); foreach (int item in myNum) { Console.WriteLine(item); } Console.ReadKey(); return; } public static int[] GetRand(int minValue, int maxValue, int count) { maxValue = maxValue - minValue + 1; int[] arrInt = new int[maxValue]; for (int i = 0; i < maxValue; i++) { arrInt[i] = i + minValue; } int[] arrResult = new int[count]; int n = maxValue; Random rand = new Random(); for (int i = 0; i < count; i++) { int index = rand.Next(0, n); arrResult[i] = arrInt[index]; arrInt[index] = arrInt[--n]; } return arrResult; }