Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Actual Random number generation

Allan#Allan# Posts: 2Member
I would like to generate a random number.
Currently im using the folowing:

using System;

private void GeraPadraoProjetado()
int i;
int seed = 2; //chosen randomly by me
Random fixRand = new Random(seed);

PadraoProjetado[i] = (int)(256*fixRand.NextDouble());

As I have observed, the generated numbers are always the same each time I execute the program.

When I programed in Visual Basic, I remember we had to use the "Randomize()" function before using the function that generated the random numbers in order to essure that the numbers would be actualy random.

Does anyone know what to do in C#?
Thanks in advance!]

Ps.: Excuse me about the code indentation, I simply didnt know how to do it here.


Sign In or Register to comment.