I am having a problem with the VB code Int(Rnd() * 75) + 75) conveting it to C#.
I have tried
Random random = new Random
random.Next( 75 ) + 75
But its isnt right. Please Help me.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming that’s meant to give a value between 75 (inclusive) and 150 (exclusive) I’d use
That’s clearer than first generating a number in the range [0, 75) and then adding 75, IMO.
Note, however, that you shouldn’t be creating a new instance of
Randomevery time you want a random number. You probably want one instance per thread. I have a reasonably long article explaining the various pitfalls in generating random numbers, and some workarounds.