title: Generate every combination of numbers
body: <p>I have an array with 100 elements, of which I randomly pick 4 (the same element can't be picked twice). I repeat this process many times, to try and get every possible combination. There must be a more efficiënt way though.</p>
  
  <p>How would I go about creating a loop that just creates every possible combination?</p>
  
  <pre><code>double[][] picked = new double[4][];
  int[] chosen = new int[4];
  Random rnd = new Random();
  List&lt;int&gt; exclude = new List&lt;int&gt;();
  int z = 0;
  while (z &lt; 4)
  {
      picked[z] = new double[rows];
      int x = rnd.Next(0, rows);
      if (exclude.Contains(x))
      {
          continue;
      }
      exclude.Add(x);
  
      // do stuff with the chosen elements
  
      z++;
  }
  </code></pre>
  
  <p>Edit: the question that was linked to as duplicate is different, as it allows for duplicate elements to be chosen.</p>
  
  <p>Found my anwser here: <a href="https://stackoverflow.com/a/17871949/1880554">https://stackoverflow.com/a/17871949/1880554</a></p>