The following function returns random number between a range
private int F(int min, int max)
{
Random _r = new Random();
int n = _r.Next(min, max);
return n;
}
You can call it N items using loop
protected void Page_Load(object sender, EventArgs e)
{
List<int> ints = new List<int>();
for (int i = 0; i < 3; i++)
{
int no = F(1, 31);
if (!ints.Exists(n => n == no))
{
ints.Add(no);
}
}
}