mardi 26 juin 2018

Visual Basic Randomize() vs New Random

It seems that Randomize() Rnd()Randomize() Rnd() aren't used anymore. Instead people make something like:

Dim rng as New Random() Dim randomNo as Integer = rng.Next(10) ‘ this is a random number between 0 and 10. Dim anotherRandomNo as Integer = rng.Next(10) ‘ a different random number.

Dim rng as New Random() Dim randomNo as Integer = rng.Next(10) ‘ this is a random number between 0 and 10. Dim anotherRandomNo as Integer = rng.Next(10) ‘ a different random number.

Could someone tell me why this is considered 'better' in most circumstances?

Thanks

Zima




Aucun commentaire:

Enregistrer un commentaire