random numbers generation

Question
I am having a small problem with random numbers generation.
I am using c#.And in that my code is like this:

Random rnd =new Random();
rnd.Next(100);

If i print these values then i am getting repeated values.
But i want unique values with this function.

I have observed that if i use vb function Randomize()
then values are not repeating.But i want to get this with
C#.


Answer
 
The following code worked fine for me.
private
void RandomNumber(int min, int max)
{
Random random = new Random();
random.Next(100);
MessageBox.Show(random.Next(100).ToString()); MessageBox.Show(random.Next(min, max).ToString());
}


No comments:

Post a Comment