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.
16 Replies - 4157 Views - Last Post: 29 April 2014 - 07:34 AM
Re: Generating unique random numbers in C#
Posted 29 April 2014 - 07:34 AM
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...