public void ShowIndexation(RangeOfArray massive, int startIndex)
 {
     for (int i = 0; i < array.Length; i++)
     {
         Console.WriteLine("array[{0}] элемент массива равен = " + array[i], (i + startIndex));
     }
 }
Пример #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Введите индексный диапазон (начало): ");
            int.TryParse(Console.ReadLine(), out int lowIndex);
            Console.WriteLine("Введите индексный диапазон (конец): ");
            int.TryParse(Console.ReadLine(), out int highIndex);
            Random random = new Random();

            if (lowIndex < highIndex)
            {
                Console.WriteLine("Нижний индекс = {0}. Вверхний индекс = {1}", lowIndex, highIndex);
                RangeOfArray range = new RangeOfArray(lowIndex, highIndex);
                for (int i = 0; i < range.array.Length; i++)
                {
                    range.array[i] = random.Next(1, 20);
                }
                range.ShowIndexation(range, lowIndex);
            }
            else
            {
                Console.WriteLine("Введены некорректные индексы!!!");
            }
            Console.ReadKey();
        }