How to generate a random 10 digit number in C#?

后端 未结 13 1887
清歌不尽
清歌不尽 2020-12-15 18:00

I\'m using C# and I need to generate a random 10 digit number. So far, I\'ve only had luck finding examples indicating min maximum value. How would i go about generating a r

13条回答
  •  感动是毒
    2020-12-15 18:39

    (1000000000,9999999999) is not random - you're mandating that it cannot begin with a 1, so you've already cut your target base by 10%.

    Random is a double, so if you want a integer, multiply it by 1,000,000,000, then drop the figures after the decimal place.

提交回复
热议问题