jeudi 19 juillet 2018

Same random sequence in VB and C#

I'm migrating an old application in VB6 to C# and I've find a problem with a random number sequence:

(pin is a number greater than 0 in string format) In my VB code, I've found:

Rnd("-" & pin)
Randomize(CDbl(pin))

So, the code generates the same number sequence all the times (read this note)

Now, in my C# code, I have:

Random r = new Random(int.Parse(pin))

But it does not generate the same sequence.

I'm trying to avoid VBMath.Rnd() instruction, if it's possible.

Please, can you tell me what is the equivalent code in C#?

Thanks a lot in advance!




Aucun commentaire:

Enregistrer un commentaire