Generate Random Boolean Probability

后端 未结 7 1605
离开以前
离开以前 2021-02-05 01:17

I only know how I can generate a random boolean value (true/false). The default probability is 50:50

But how can I generate a true false value with my own probability? L

相关标签:
7条回答
  • 2021-02-05 02:06

    I think it can help you

    Random gen = new Random();
    bool result = gen.Next(100) < 50 ? true : false;
    
    0 讨论(0)
提交回复
热议问题