title: Unique permutation in c# gives no dup but vb.net does
body: <p>So I am converting an extension method to find permutations of a generic list from c# to vb
  The code in c# does not return duplicate. For example: {1,2} is same as {2,1} and {1,1} is not allowed. The vb code that I convert, however gives me a duplicate. Can someone help me spot the problem. I got the c# code from accepted answer in this thread: <a href="https://stackoverflow.com/questions/1119699/how-to-generate-combinations-of-elements-of-a-listt-in-net-4-0">How to Generate Combinations of Elements of a List&lt;T&gt; in .NET 4.0</a></p>
  
  <p>Here is the vb code:</p>
  
  <pre><code>Module HelperPermutation
  &lt;Extension()&gt;
  Public Function Combinations(Of T)(elements As IEnumerable(Of T), k As Integer) As IEnumerable(Of T())
      Dim result As List(Of T()) = New List(Of T())
      If (k = 0) Then
          result.Add(New T(-1) {})
      Else
          Dim current As Integer = 1
          For Each element In elements
              result.AddRange(elements _
                              .Skip(current = current + 1) _
                              .Combinations(k - 1) _
                              .Select(Function(c) (New T() {element}).Concat(c).ToArray())
                              )
          Next
      End If
      Return result
  End Function
  End module
  </code></pre>
  
  <p>I tried to add Distinct but it still gives me duplicates.
  And this is my console app to use that extension method:</p>
  
  <pre><code>Dim list As New List(Of Integer) From {1, 2, 3}
      Dim array = list.Combinations(2)
      Console.WriteLine("# of permutation: " &amp; array.Count)
      For Each value In array
          Console.WriteLine("-------Pairs: " &amp; value.Count)
          For i As Integer = 0 To value.Count - 1 Step 1
              Console.WriteLine("value = " &amp; value.ElementAt(i))
          Next
      Next
  
      Console.ReadLine()
  </code></pre>