title: Why doesn't the Union function in LINQ remove duplicate entries?
body: <p>I'm using VB .NET and I know that Union normally works ByRef but in VB, Strings are generally processed as if they were primitive datatypes.</p>
  
  <p>Consequently, here's the problem:</p>
  
  <pre><code>Sub Main()
      Dim firstFile, secondFile As String(), resultingFile As New StringBuilder
  
      firstFile = My.Computer.FileSystem.ReadAllText(My.Computer.FileSystem.SpecialDirectories.Desktop &amp; "\1.txt").Split(vbNewLine)
      secondFile = My.Computer.FileSystem.ReadAllText(My.Computer.FileSystem.SpecialDirectories.Desktop &amp; "\2.txt").Split(vbNewLine)
  
      For Each line As String In firstFile.Union(secondFile)
          resultingFile.AppendLine(line)
      Next
  
      My.Computer.FileSystem.WriteAllText(My.Computer.FileSystem.SpecialDirectories.Desktop &amp; "\merged.txt", resultingFile.ToString, True)
  End Sub
  </code></pre>
  
  <p>1.txt contains:<br>
  a<br>
  b<br>
  c<br>
  d<br>
  e  </p>
  
  <p>2.txt contains:<br>
  b<br>
  c<br>
  d<br>
  e<br>
  f<br>
  g<br>
  h<br>
  i<br>
  j</p>
  
  <p>After running the code, I get:<br>
  a<br>
  b<br>
  c<br>
  d<br>
  e<br>
  b<br>
  f<br>
  g<br>
  h<br>
  i<br>
  j</p>
  
  <p>Any suggestions for making the Union function act like its mathematical counterpart?</p>