hi,
I want to generate unique random numbers,
suppose, N be number of random nos to generate and MIN and MAX is the range.
Then how do u i get those N numbers which are unique and random?
i hv code snippet like this,
int
minNumber=0;Random r = new Random();
// Use an list to store generated numbers
List<int> uniqueRandNos = new List<int>(); // Create the unique random numbers do{
int testNum = r.Next(minNumber, maxNumber); // Have we added this value already? if (!uniqueRandNos.Contains(testNum)){
uniqueRandNos.Add(testNum);
}
}
while (uniqueRandNos.Count < numberOfSelections); return uniqueRandNos;
Whether this is feasible for real time systems....?
haisum bhattiPosted Mar 26, 2010, 5:55 PM
Ryan AlfordPosted Jan 23, 2009, 11:46 AM