Click here to Skip to main content
15,887,676 members
Home / Discussions / C#
   

C#

 
GeneralRe: Random numbers PinPopular
David19876-May-11 3:45
David19876-May-11 3:45 
AnswerRe: Random numbers Pin
Luc Pattyn6-May-11 3:52
sitebuilderLuc Pattyn6-May-11 3:52 
GeneralRe: Random numbers PinPopular
David19876-May-11 3:57
David19876-May-11 3:57 
GeneralRe: Random numbers Pin
PIEBALDconsult6-May-11 16:19
mvePIEBALDconsult6-May-11 16:19 
GeneralRe: Random numbers Pin
David19876-May-11 21:41
David19876-May-11 21:41 
AnswerRe: Random numbers Pin
Orcun Iyigun6-May-11 8:37
Orcun Iyigun6-May-11 8:37 
AnswerRe: Random numbers Pin
Prasanta_Prince6-May-11 15:32
Prasanta_Prince6-May-11 15:32 
GeneralRe: Random numbers Pin
meet_ssr6-May-11 22:30
meet_ssr6-May-11 22:30 
Hello,
How do I generate random numbers, say between 1 and 10, that return all the 10 numbers without repeatedly looping? Is there a way doing that in C#?

Thanks David, Luc Pattyn, PIEBALDconsult, orc_orc_orc, Prasanta_Prince for your all your responses and appreciate your time. I'll try the solutions provided by you

Little clarification on 'Repeatedly looping' (sorry for not being clear):
Lets say that if I want to generate random numbers between 1 and n, I use, say, rand() method that returns a random value every time I call this method. But there are chances that I get duplicate numbers being generated. So I need to skip (ignore) this duplicate number since it was already generated. But there is no guarantee that the same number doesn't appear again and again. So I need to keep looping until I get all the n numbers. The number of loops could grow as n grows, say 500. Is there a way to avoid the duplicates without doing a 'check' so that I can avoid extra loops? Performance is a concern.

Again thanks for your responses.
AnswerRe: Random numbers Pin
lampiclobe7-May-11 0:49
lampiclobe7-May-11 0:49 
GeneralRe: Random numbers Pin
meet_ssr8-May-11 20:54
meet_ssr8-May-11 20:54 
AnswerRe: Random numbers Pin
lampiclobe10-May-11 11:56
lampiclobe10-May-11 11:56 
AnswerRe: Random numbers Pin
#realJSOP7-May-11 1:33
mve#realJSOP7-May-11 1:33 
RantRe: Random numbers Pin
lampiclobe7-May-11 12:26
lampiclobe7-May-11 12:26 
GeneralRe: Random numbers Pin
#realJSOP7-May-11 12:47
mve#realJSOP7-May-11 12:47 
GeneralRe: Random numbers Pin
lampiclobe7-May-11 20:45
lampiclobe7-May-11 20:45 
Questionadd and not add button "show data" in to Datagrid in C# ???? Pin
aa_zz6-May-11 0:19
aa_zz6-May-11 0:19 
AnswerRe: add and not add button "show data" in to Datagrid in C# ???? Pin
Ravi Sant6-May-11 1:17
Ravi Sant6-May-11 1:17 
QuestionHow to resolve the XML Error Pin
meeram3955-May-11 22:40
meeram3955-May-11 22:40 
AnswerRe: How to resolve the XML Error Pin
Pete O'Hanlon5-May-11 23:09
mvePete O'Hanlon5-May-11 23:09 
GeneralRe: How to resolve the XML Error Pin
meeram3955-May-11 23:18
meeram3955-May-11 23:18 
GeneralRe: How to resolve the XML Error Pin
Pete O'Hanlon6-May-11 0:13
mvePete O'Hanlon6-May-11 0:13 
AnswerRe: How to resolve the XML Error Pin
Eddy Vluggen6-May-11 0:04
professionalEddy Vluggen6-May-11 0:04 
GeneralRe: How to resolve the XML Error Pin
meeram3956-May-11 0:14
meeram3956-May-11 0:14 
GeneralRe: How to resolve the XML Error Pin
Eddy Vluggen6-May-11 0:36
professionalEddy Vluggen6-May-11 0:36 
GeneralRe: How to resolve the XML Error Pin
meeram3956-May-11 1:21
meeram3956-May-11 1:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.