title: Implement "percent chance" in C#
body: <p>I need some help with percent chance in C# code. Let's say i have for loop from 1 to 100 and in that loop i have an "if" code that i want to be executed 70% times (on random). How would i achieve that? So something like this:</p>
  
  <pre><code>static void Main(string[] args)
  {
      var clickPercentage = 70;
  
      for (int i = 0; i &lt; 100; i++)
      {
          if (chance)
          {
              //do 70% times
          }
      }
  }
  </code></pre>
  
  <p>So for top example i would want if code to be hit with a chance of 70%, about 70 times for my example. </p>
  
  <p>Things i tried: (nowhere near 70%, more like 1 or 2% chance)</p>
  
  <pre><code>static void Main(string[] args)
  {
      var clickPercentage = 70;
  
      for (int i = 0; i &lt; 100; i++)
      {
          var a = GetRadnomNumber(1, clickPercentage);
          var b = GetRadnomNumber(1, 101);
  
          if (a &lt;= b)
          {
              Console.WriteLine($"Iteracija {i} - {b} &lt;= {a}");
          }
      }
  }
  
  public static int GetRadnomNumber(int min, int max)
  {
      var random = new Random();
      var retVal = random.Next(min, max);
  
      return retVal;
  }
  </code></pre>