Click here to Skip to main content
15,889,874 members
Home / Discussions / C#
   

C#

 
QuestionDrawing string in reverse color? Pin
Ali Beirami7-Oct-05 19:36
Ali Beirami7-Oct-05 19:36 
AnswerRe: Drawing string in reverse color? Pin
S. Senthil Kumar7-Oct-05 20:44
S. Senthil Kumar7-Oct-05 20:44 
QuestionTransparent proxy in C# Pin
Anonymous7-Oct-05 19:14
Anonymous7-Oct-05 19:14 
AnswerRe: Transparent proxy in C# Pin
M.A. Agheli7-Oct-05 22:44
M.A. Agheli7-Oct-05 22:44 
AnswerRe: Transparent proxy in C# Pin
leppie8-Oct-05 0:59
leppie8-Oct-05 0:59 
GeneralRe: Transparent proxy in C# Pin
M.A. Agheli8-Oct-05 1:07
M.A. Agheli8-Oct-05 1:07 
GeneralRe: Transparent proxy in C# Pin
Member 368719017-Jul-09 3:38
Member 368719017-Jul-09 3:38 
QuestionRandom numbers Pin
steveski747-Oct-05 18:13
steveski747-Oct-05 18:13 
Hi,

I'm having some trouble with random numbers.
I'm building a BTree structure but wether the node I'm inserting goes left or right needs to be random.
The problem is that:
Random rand = new Random();
int num = rand.Next(1,3);
always produces the same number everytime time the function is called.
I tried generating 2000 numbers in a list and found that about 1/3 were 2, the next 1/3 were 1 and the next 1/3 were 2.
Basically the default seed is the current time's Millisecond property.
I tried setting my own seed and had the same results.

If I do System.Threading.Thread.Sleep(1000) I get what looks like a valid set of random numbers.
The problems is I can't wait for 1 second per Random number as I need to make thousands of these decisions in a short space of time.

Is there a seed I can provide, mayve a smaller number than Millisecond?
I was thinking of having an array of seeds, and everytime I need a random numbr, then choose the next seed in the list, and add it to the current time.
This way, even when the same element of the array is selected when it loops around the seed will be different.
The problem is I really couldn't be bothered coming up with thousands of numbers for this.

Is there an easier way?


Thanks,

Stephen York
AnswerRe: Random numbers Pin
steveski747-Oct-05 21:11
steveski747-Oct-05 21:11 
GeneralRe: Random numbers Pin
leppie8-Oct-05 1:03
leppie8-Oct-05 1:03 
Questionconvert image to icon Pin
Mridang Agarwalla7-Oct-05 17:43
Mridang Agarwalla7-Oct-05 17:43 
AnswerRe: convert image to icon Pin
steveski747-Oct-05 21:12
steveski747-Oct-05 21:12 
QuestionHow to return the result of a function in a thread? Pin
rushing7-Oct-05 15:24
rushing7-Oct-05 15:24 
AnswerRe: How to return the result of a function in a thread? Pin
S. Senthil Kumar7-Oct-05 20:50
S. Senthil Kumar7-Oct-05 20:50 
QuestionThe TcpClient is so slowly to create. Pin
rushing7-Oct-05 15:21
rushing7-Oct-05 15:21 
Questionc# 2.0 exam Pin
fmardani7-Oct-05 10:25
fmardani7-Oct-05 10:25 
AnswerRe: c# 2.0 exam Pin
enjoycrack7-Oct-05 10:37
enjoycrack7-Oct-05 10:37 
QuestionStatic Method Variables Pin
tsramkumar7-Oct-05 9:27
tsramkumar7-Oct-05 9:27 
AnswerRe: Static Method Variables Pin
Daniel Grunwald7-Oct-05 9:43
Daniel Grunwald7-Oct-05 9:43 
GeneralRe: Static Method Variables Pin
tsramkumar7-Oct-05 9:44
tsramkumar7-Oct-05 9:44 
AnswerRe: Static Method Variables Pin
S. Senthil Kumar7-Oct-05 20:56
S. Senthil Kumar7-Oct-05 20:56 
GeneralRe: Static Method Variables Pin
tsramkumar8-Oct-05 17:46
tsramkumar8-Oct-05 17:46 
AnswerRe: Static Method Variables Pin
Tom Larsen8-Oct-05 9:19
Tom Larsen8-Oct-05 9:19 
QuestionInternal Rate of Return code (IRR) Pin
zaboboa7-Oct-05 9:07
zaboboa7-Oct-05 9:07 
AnswerRe: Internal Rate of Return code (IRR) Pin
leppie7-Oct-05 11:21
leppie7-Oct-05 11: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.