Generating random, unique values C#

前端 未结 17 1151
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 14:26

I\'ve searched for a while and been struggling to find this, I\'m trying to generate several random, unique numbers is C#. I\'m using System.Random, and I\'m us

17条回答
  •  北海茫月
    2020-11-22 14:52

    You can use basic Random Functions of C#

    Random ran = new Random();
    int randomno = ran.Next(0,100);
    

    you can now use the value in the randomno in anything you want but keep in mind that this will generate a random number between 0 and 100 Only and you can extend that to any figure.

提交回复
热议问题