Generating unique random numbers in C#

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 2220 Views - Last Post: 29 April 2014 - 07:34 AM Rate Topic: -----

#16 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3662
  • View blog
  • Posts: 11,466
  • Joined: 05-May 12

Re: Generating unique random numbers in C#

Posted 29 April 2014 - 05:50 AM

Yup. That's called scoping.

By scoping your variables to just where you need them, you set yourself up for success later when you need to refactor the code and have minimal impact on the lines of code around it.
Was This Post Helpful? 1
  • +
  • -

#17 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5932
  • View blog
  • Posts: 12,854
  • Joined: 16-October 07

Re: Generating unique random numbers in C#

Posted 29 April 2014 - 07:34 AM

View PostMomerath, on 28 April 2014 - 09:32 PM, said:

That was my thought too, Skydiver, when I first read this. But I'd have used Enumerable.Range to fill the array :)


At that point, just use an OrderBy and call it a day...
Spoiler

Was This Post Helpful? 3
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2