.NET Fiddle

CSharp · Console

/Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
					
public class Program
{
	public static void Main()
	{
		foreach (int prime in GetPrimes(100,200)) {
			Console.Write(prime.ToString()+" ");
		}
		Console.WriteLine();
	}
	
	private static List<int> GetPrimes(int lo, int hi)
    {
        var primes = new List<int> {2};
        for (int i = 3; i <= hi; i+=2) {
            var maxFactor = Math.Sqrt(i);
            foreach (int factor in primes) {
                if (factor > maxFactor) break;
                if (i % factor == 0) {
                    goto not_prime;
                }
            }
            primes.Add(i);
            not_prime:;
        }
        return primes.Where(p => lo <= p && p <= hi).ToList();
    }
}
;