Index was outside the bounds of array

Last Reply on Jun 26, 2012 07:00 AM By Mudassar

Posted on Jun 26, 2012 04:15 AM
public static void Main()
        {
            int[] number={1,1,3,3,3,5,5,5,9,9,9,9};
            int n = number.Length;
            for (int i = 0; i < n; i++)
            {
                if (number[i] != number[i + 1])
                {
                    Console.WriteLine(number[i]);

                }
                    
                   
            }

        }

Please correct me

You are viewing reply posted by: Mudassar on Jun 26, 2012 07:00 AM.
Posted on Jun 26, 2012 07:00 AM

Because of checking

number[i] != number[i + 1]

I agree, here is the link: http://e-iceblue.com/free-api