Generate random 6 digit number

前端 未结 6 2303
南方客
南方客 2020-12-29 20:25

I\'ve been searching for a couple of hours and I just can\'t seem to find a answer to this question. I want to generate a random number with 6 digits. Some of you might tell

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-29 20:49

    string s = generator.Next(0, 1000000).ToString("D6");
    

    or

    string s = generator.Next(0, 1000000).ToString("000000");
    

提交回复
热议问题