Hello guys,
Am using a random number generator in a loop
I used this function to generate random number in vb.net and it worked fine
vb Code:
'//Generate RandomNumber Private Function RandomNum(ByVal Lower As Long, _ ByVal Upper As Long) As Long Randomize(Timer) RandomNum = Rnd() * (Upper - Lower + 1) + Lower End Function
Converting to c# made is extremely slow
c# Code:
////Generate RandomNumber private int RandomNum(int Lower, int Upper) { System.Random RandNum = new System.Random(); int MyRandomNumber = RandNum.Next(Lower, Upper); System.Threading.Thread.Sleep(100);// this line makes the random generator give unique value return MyRandomNumber; }
Please can you help me uptimize it?





Reply With Quote