One way is checking that the return value of Random.Next(100)
is less than your desired probability. I can’t speak to the true ‘randomness’ of this method though.
Proper example, using desired probability of 20%:
Random gen = new Random();
int prob = gen.Next(100);
return prob < 20;