Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
How to generate random number without repetition in C #
Posted 26-Nov-12 0:39am
Comments
digimanus at 26-Nov-12 5:41am
   
show us your code
rasol123 at 26-Nov-12 5:49am
   
Function to prevent the entry of the previously random number is generated, for example, in VB
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Provided the set of possible candidates is 'reasonably small', I described a method here: "Random extraction of 5 cards from a deck"[^]. Is C++ code, but, in this case, just the algorithm matters.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

GUID, that is what you use[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

you can use Random class of .NET.
 
use following code:
 
Random random = new Random();
int num = random.Next();
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Hi,
 
use the below code to generate.
Random integer between 0 and 100 here 100 is not included)
Random random = new Random();
int randomNumber = random.Next(0, 100);//Give the range in which you want to generate.

;
 
Or refer the below link.
Random Number Generation[^]
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 320
1 DamithSL 265
2 CPallini 235
3 Maciej Los 190
4 Sergey Alexandrovich Kryukov 184
0 OriginalGriff 5,415
1 DamithSL 4,422
2 Maciej Los 3,820
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,911


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 26 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100