Random Number Generation
Hi All
I have following problem with random number generation. I have 10 images, which i have to display in random order each time i refresh my form, but the problem is that .net random function generates the same sequence each time.
Here is my Code
public static DataTable GetRandomJobLogos(DataTable dataTable){
int totalRows = jobSourceDataTable.Rows.Count;
DataTable tempDataTable = dataTable.Clone();
ArrayList numberList = new ArrayList();
Random rand = new Random(0);
for (int i = 0; i < totalRows; i++){
int randomRowNum = rand.Next(totalRows);
if (!numberList.Contains(randomRowNum)){
numberList.Add(randomRowNum);
tempDataTable.ImportRow(dataTable.Rows[randomRowNum]);
}
else{
i--;
}
}
}
entries in tempDataTable are always in same order.
am i doing some wrong, or there can be any better way to do this?
|