Getting prime numbers between a range
If you are only executing this once, it should work fine as is.  If you are going to execute it more than once per century, you should use the Sieve of Eratosthenes, as suggested by Somnath Rakshit.

Using the algorithm as described on wikipedia:

static class MathExtensions
{
    static public List&lt;int&gt; GetPrimes(int start, int end)
    {
        List&lt;int&gt; res = new List&lt;int&gt;();

        // 1. Create a list of consecutive integers from 2 through n: (2, 3, 4, ..., n).
        int[] numbers = Enumerable.Range(0, end).ToArray();

        // 2. Initially, let p equal 2, the first prime number.
        int idx = 2;
        do
        {
            // If the number is in range, add it to the result
            if (numbers[idx] &gt;= start)
            {
                res.Add(numbers[idx]);
            }

            // 3. Starting from p, enumerate its multiples by counting to n in increments of p, and mark them in the list (these will be 2p, 3p, 4p, ... ; the p itself should not be marked).
            for (var i = idx; i &lt; end; i += idx)
            {
                numbers[i] = 0;
            }

            // 4. Find the first number greater than p in the list that is not marked. If there was no such number, stop. Otherwise, let p now equal this new number (which is the next prime), and repeat from step 3.
            while (idx &lt; end &amp;&amp; numbers[idx] == 0)
            {
                idx++;
            }
        }
        while (idx &lt; end);

        return res;
    }
}