Q:

Range of a string program

This is a program to get all the letters in a string in a specified range (in this case characters 3 through 7 of the word 'kangaroo').
Why am i getting an error at line arr[i] = x[start+i];? 
I am not using Substring because my instructor wants us to figure out how to do it without it as an exercise.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MethodsPractice2
{
    class Program
    {
        static char[] GetRangeOfCharacters(string word, int start, int end)
        {
            string x = word;
            char[] arr = new char[end - start];

            for (int i = 0; i < end; i++)
            {
                arr[i] = x[start + i];
            }

            return arr;
        }

        private static void Main(string[] args)
        {
            char[] endResult;
            string word = "kangaroo";
            int start = 3;
            int end = 7;
            endResult = GetRangeOfCharacters(word, start, end);
            Console.WriteLine(endResult);
        }
    }
}

A:

I'll explain the error you are getting,
You have said that you wish to start at character 3, and fill arr which is has 4 entries, with the characters that start at (3) + i
i can be any number less than 7.. 3 + 6 = 9; and Kangaroo has 8 letters in it... therefore you for loop at the minimum needs to go to 
i < (end - start)

The other error could could get is i >= 4 in which case it would be trying to access arr[4] which is also out of range

0123456789
kangaroo
garo##  /// what arr would be - # = error
garoo#   // where i would get you - # = error

