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

C#

 
GeneralRe: pass a Size object to sendmessage Pin
manchukuo6-May-11 8:12
manchukuo6-May-11 8:12 
GeneralRe: pass a Size object to sendmessage Pin
DaveyM696-May-11 8:27
professionalDaveyM696-May-11 8:27 
GeneralRe: pass a Size object to sendmessage [modified] Pin
manchukuo6-May-11 8:30
manchukuo6-May-11 8:30 
GeneralRe: pass a Size object to sendmessage [modified] Pin
DaveyM696-May-11 9:26
professionalDaveyM696-May-11 9:26 
GeneralRe: pass a Size object to sendmessage Pin
DaveyM696-May-11 10:13
professionalDaveyM696-May-11 10:13 
GeneralRe: pass a Size object to sendmessage Pin
DaveyM696-May-11 11:11
professionalDaveyM696-May-11 11:11 
GeneralRe: pass a Size object to sendmessage Pin
manchukuo6-May-11 11:14
manchukuo6-May-11 11:14 
QuestionRandom numbers [modified] Pin
meet_ssr6-May-11 2:46
meet_ssr6-May-11 2:46 
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.
modified on Saturday, May 7, 2011 3:38 AM

AnswerRe: Random numbers Pin
PIEBALDconsult6-May-11 2:52
mvePIEBALDconsult6-May-11 2:52 
GeneralRe: Random numbers PinPopular
David19876-May-11 2:56
David19876-May-11 2:56 
AnswerRe: Random numbers Pin
Luc Pattyn6-May-11 3:06
sitebuilderLuc Pattyn6-May-11 3:06 
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 
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 

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.