R
Roy Gourgi
Hi,
How do I invoke the random number generator that was suggested by a few
people. Ideally, what I would like to do is to instantiate the random no.
generator with a seed value that does not repeat the values and that can be
called from any class, as I have to call the random number generator from a
few different classes.
Here is my code:
using System;
class cMain
{
static void Main()
{
}
}
public class cGetRandom
{
static Random rand = new Random();
private static int GetRandom()
{
lock ( rand )
{
return rand.Next();
}
}
}
public class cClass1
{
private static int Class1()
{
int lnRand=0;
lnRand=cGetRandom.rand.Next(1, 49);
}
}
TIA
Roy
How do I invoke the random number generator that was suggested by a few
people. Ideally, what I would like to do is to instantiate the random no.
generator with a seed value that does not repeat the values and that can be
called from any class, as I have to call the random number generator from a
few different classes.
Here is my code:
using System;
class cMain
{
static void Main()
{
}
}
public class cGetRandom
{
static Random rand = new Random();
private static int GetRandom()
{
lock ( rand )
{
return rand.Next();
}
}
}
public class cClass1
{
private static int Class1()
{
int lnRand=0;
lnRand=cGetRandom.rand.Next(1, 49);
}
}
TIA
Roy