Want to produce random numbers between 1-45 without repetition
I have come across a very strange problem. I have tried to find its solution but in vain. My problem is that I want to create a random number between 1-45 and I don't want that number to repeat again. Random selection, by definition, will repeat randomly. However, you can build an array containing each of your numbers and then shuffle the array, producing a random order of numbers without repetition. var nums = [], i; for( i=1; i<=45; i++) nums.push(i); nums.sort(function(a,b) {return Math.random()-0.5;}); alert(nums.join(",")); This is Working code.. Random rd =new Random(); int n = rd.Next(1