public static int[] RandomNumbers(int n,int min,int max)

{

    Random rnum = new Random();

    HashSet hset = new HashSet();

    while (hset.Count < n)

        hset.Add(rnum.Next(min,max));

    int[] OutPut = hset.ToArray();

    return OutPut;

}