Newbie Syntax Question on use of System.Random.

G

Gomere

I am trying to use the System.Random.Next method in a class/subroutine.

I have tried using things like this:

private System.Random Rnd;

....

return ( x * Rnd.Next(1000) );

The Intellisense picks it up as legal, but the debugger says it's Null...
etc.

If someone could point me in the right direction, I would appreciate it.
 
M

Mikael Jansson

You need to instantiate the object.

private System.Random Rnd = new System.Random();
.....
return(x * Rnd.Next(1000));

/Mikael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top