Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 26th, 2012  |  syntax: None  |  size: 0.36 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Random.Next() - finding the Nth .Next()
  2. static int GetRandomNumber(int index)
  3. {
  4.     return new Random(index).Next();
  5. }
  6.        
  7. Random rnd = new Random(0);
  8. Dictionary<int,int> randomNumbers = new Dictionary<int,int>();
  9. int getRandomNumber(int index)
  10. {
  11.     if (!randomNumbers.ContainsKey(index))
  12.         randomNumbers[index] = rnd.Next();
  13.     return randomNumbers[index];
  14. }