Answers for "c# chance of"

C#
0

c# chance of

public static Random RandomGen = new Random();
.....

int clickPercentage = 70;
for (int i = 0; i < 100; i++)
{
    int randomValueBetween0And99 = RandomGen.Next(100);
    if (randomValueBetween0And99 < clickPercentage)
    {
        //do 70% times
    }
}
Posted by: Guest on October-08-2021

C# Answers by Framework

Browse Popular Code Answers by Language