'Does "for loop" needs to start at 0 when we are trying to assign the number to array which we get it from user?

I am having a issue which related to loops.

            int[] numbers= new int[5];
            for (int i = 0; i < 5; i++)
            {
                Console.WriteLine("Enter a number: ");
                numbers[i] = Convert.ToInt32(Console.ReadLine());
            }

            Array.Sort(numbers);

            foreach (int i in numbers)
            {
                Console.WriteLine(i);

            }
            Console.ReadLine();

İf i try to change the for (int i = 0; i < 5; i++) to for (int i = 1; i < 6; i++). It gives me:System.IndexOutOfRangeException: 'Index was outside the bounds of the array.'.

What is the difference between these two?

  1. int i=0; i<5; i++ => 0->1->2->3->4 Length of array:5
  2. int i=1; i<6; i++ => 1->2->3->4->5 Length of array:5


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source