I have a situation in which I have to create a random number, this number should be either zeroorone
So, the code looks something like this:
randomNumber = new Random().Next(0,1)
However, business requirements indicate that the probability of 10% of the number just generated is zero and 90% of the probability that the number generated is 1
However, can I include this probability when generating a random number?
What I was thinking:
- Generate an array of integers including 10 zeros and 90 units.
- Create a random index between 1 and 100
- Take the value corresponding to this index
But I don’t know if this is the right way, plus, I think C # should have something ready for it