title: All permutations of a list
body: <p>I'd like to be able to take a list like this</p>
  
  <pre><code>var list=new List&lt;int&gt;{0, 1, 2};
  </code></pre>
  
  <p>And get a result like this</p>
  
  <pre><code>var result=
      new List&lt;List&lt;int&gt;&gt;{
          new List&lt;int&gt;{0, 1, 2},
          new List&lt;int&gt;{0, 2, 1},
          new List&lt;int&gt;{1, 0, 2},
          new List&lt;int&gt;{1, 2, 0},
          new List&lt;int&gt;{2, 0, 1},
          new List&lt;int&gt;{2, 1, 0}
      };
  </code></pre>
  
  <p>I'm not interested in sets with missing numbers, just combinations of the numbers that exist. Any ideas?</p>
  
  <hr>
  
  <p>Also, I've looked into solutions like <a href="https://stackoverflow.com/questions/3319586/getting-all-possible-permutations-from-a-list-of-numbers">Getting all possible combinations from a list of numbers</a> already, and they don't fit. </p>
  
  <p>That one gives me something like this </p>
  
  <pre><code>var result=
      new List&lt;List&lt;int&gt;&gt; {
          // [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]
          // serialized the result to JSON so it would be quicker.
      };
  </code></pre>
  
  <p>And it doesn't spit out all of the combinations. </p>
  
  <hr>