How do you generate a random number in C#?

前端 未结 6 1801
天命终不由人
天命终不由人 2020-12-25 12:34

I would like to generate a random floating point number between 2 values. What is the best way to do this in C#?

6条回答
  •  难免孤独
    2020-12-25 12:55

    For an explaination of why Longhorn has been downmodded so much: http://msdn.microsoft.com/en-us/magazine/cc163367.aspx Look for the implementation of NextDouble and the explanation of what is a random double.

    That link is also a goo example of how to use cryptographic random numbers (like Sameer mentioned) only with actual useful outputs instead of a bit stream.

提交回复
热议问题