Create random number array
<pre><code>using System;
using System.Linq;
using System.Text;

namespace RandomArray
{
    class Program
    {
        readonly int[] _result;     //  This will be initialized to an array of 1000 to contain the results
        readonly int[] _samples;    //  A sample array to store the sample size of 10 random numbers

        readonly int _randomLimit;  //  The range limit to be used in the Random.Next() function

        int _samplesCounter;        //  Array index for the sample size array

        private const int ArrayLimit = 1000;
        static readonly string Stars = new string('=', 36);

        /// &lt;summary&gt;
        /// Constructor. Local variables are initialized here
        /// &lt;/summary&gt;
        public Program()
        {
            _samples = new int[10];
            _result = new int[ArrayLimit];

            _samplesCounter = 0;

            _randomLimit = 10;
        }

        /// &lt;summary&gt;
        /// Check for the presence of the input number in the sample array and if not present then 
        /// add the value to the sample array
        /// &lt;/summary&gt;
        /// &lt;param name="value"&gt;The number to be checked against the sample size&lt;/param&gt;
        /// &lt;returns&gt;True if the value is found in the sample array, else False&lt;/returns&gt;
        bool IsInSamples(int value)
        {
            if (_samples.Any(t =&gt; t == value))
                return true;

            _samples[_samplesCounter++] = value;
            return false;
        }

        /// &lt;summary&gt;
        /// This method populates the results array with numbers from 1 to 1000 in a random order.
        /// The method generates 10 random numbers and extrapolates to fill the array
        /// &lt;/summary&gt;
        /// &lt;returns&gt;Array of numbers from 1 to 1000 in a random order&lt;/returns&gt;
        int[] GetRandomNumbers()
        {
            var resultCounter = 0;

            var random = new Random();
            for (var i = 0; i &lt; _randomLimit; i++)
            {
                var value = random.Next(1, _randomLimit + 1);

                //  Ensure that the random value is used only once
                while (IsInSamples(value))
                    value = random.Next(1, _randomLimit + 1);

                while (value &lt;= ArrayLimit)
                {
                    _result[resultCounter++] = value;
                    value += 10;
                }
            }
            return _result;
        }

        /// &lt;summary&gt;
        /// Entry point for the application
        /// &lt;/summary&gt;
        static void Main()
        {
            var start = DateTime.Now;

            var program = new Program();

            //  Get random numbers
            var result = program.GetRandomNumbers();

            var end = DateTime.Now;

            //  Print the statistics

            //  ---------------------------------------------------------------------------------
            //  Header
            //  ---------------------------------------------------------------------------------
            Console.WriteLine("{0}\nRANDOM ARRAY GENERATOR : STATISTICS\n{1}\n", Stars, Stars);


            //  ---------------------------------------------------------------------------------
            //  Count
            //  ---------------------------------------------------------------------------------
            Console.WriteLine("1. Total number of items in array: {0}\n", result.Count());


            //  ---------------------------------------------------------------------------------
            //  Check if any number repeats more than once
            //  ---------------------------------------------------------------------------------
            var group = (from r in result
                         group r by r into g
                         orderby g.Count() descending
                         select new { Item = g.Key, Count = g.Count() }
                        ).First();

            if (group.Count &gt; 1)
                Console.WriteLine("2. ***WARNING*** {0} repeats {1} time(s)\n", group.Item, group.Count);
            else
                Console.WriteLine("2. No number is repeating more than once\n");


            //  ---------------------------------------------------------------------------------
            //  Check-sum
            //  ---------------------------------------------------------------------------------
            //  The sum of the number of items in the array should match the sum of numbers from 1 to 1000
            //  Using the formula:
            //      Sum of first 'n' natural numbers = (n * (n + 1)) / 2

            //  Calculate the sum of first 1000 natural numbers
            const int n = 1000;
            const int nSum = n * (n + 1) / 2;

            //  Calculate array sum
            var arraySum = result.Sum();

            if (arraySum == nSum)
                Console.WriteLine("3. Check sum matches the sum of first 1000 natural numbers: {0} \n", arraySum);
            else
                Console.WriteLine("3. ***WARNING*** Check sum is not matching the sum of first 1000 natural numbers ({0})\n", nSum);


            //  ---------------------------------------------------------------------------------
            //  Time lapsed
            //  ---------------------------------------------------------------------------------
            var span = (end - start);
            Console.WriteLine("4. Time taken for processing: {0} ms \n", span.Milliseconds);

            //  ---------------------------------------------------------------------------------
            //  Now Print all numbers in the array
            //  ---------------------------------------------------------------------------------
            Console.WriteLine("\nNumbers in the array:\n\n");

            var sb = new StringBuilder();
            var columnCounter = 1;
            foreach (var i in result)
            {
                sb.AppendFormat("{0}   ", Convert.ToString(i).PadLeft(4, Convert.ToChar(" ")));
                if ((columnCounter++) % 10 == 0) sb.Append("\n");
            }
            Console.WriteLine(sb.ToString());

            Console.WriteLine("\n\nPress any key to exit program...");
            Console.Read();
        }
    }
}
</code></pre>

<p>Now what to do?</p>
