Create a class tha looks something like this:
public class RandomValuesHash : HashSet<int>
{
public int MaxCount { get; set; }
public int MinValue { get; set; }
public int MaxValue { get; set; }
public int MinDelta { get; set; }
private Random random = new Random(DateTime.Now.Milliseconds);
public RandomValuesHash()
{
this.MaxCount = 100;
this.MinValue = 1;
this.MaxValue = 200;
this.MinDelta = 90;
AddValues();
}
public void AddValues()
{
if (this.Count <= this.MinDelta)
{
while (this.Count < MAX_COUNT)
{
this.Add(random.Next(this.MinValue, this.MaxValue));
}
}
}
public void RemoveItem(int index)
{
this.RemoveAt(index, 1);
}
public int GetNextValue()
{
int value = this[0];
RemoveItem(0);
AddValues();
return value;
}
}
The class above takes care of all the details, so all you have to do is instantiate when the app starts, and then start retrieving values from it. The list maintains itself.
RandomValuesHash randomSet = new RandomValuesHash() { set your properties here if ou want something other than the defaults };
int newRandomValue = randomSet.GetNextValue();
To be brutally honest, when I gave you the description of what you needed to do, you shouldhave been able to do it (or figure it out on your own. Part of being a programmer is being able to analyze and design a solution as well as implement it. The implementation (writing the code) is the easy part, especially if the analysis and design have been done beforehand.