Unique 4 digit random number in C#

前端 未结 11 1911
失恋的感觉
失恋的感觉 2021-01-01 13:19

I want to generate an unique 4 digit random number. This is the below code what I have tried:

Code for generating random number

//Ge         


        
11条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-01 13:59

    Random generator = new Random();
    string number = generator.Next(1, 10000).ToString("D4");
    

提交回复
热议问题