title: Union Vs Concat in Linq
body: <p>I have a question on <code>Union</code> and <code>Concat</code>.</p>
  <pre><code>var a1 = (new[] { 1, 2 }).Union(new[] { 1, 2 });             // O/P : 1 2
  var a2 = (new[] { 1, 2 }).Concat(new[] { 1, 2 });            // O/P : 1 2 1 2
  
  var a3 = (new[] { &quot;1&quot;, &quot;2&quot; }).Union(new[] { &quot;1&quot;, &quot;2&quot; });     // O/P : &quot;1&quot; &quot;2&quot;
  var a4 = (new[] { &quot;1&quot;, &quot;2&quot; }).Concat(new[] { &quot;1&quot;, &quot;2&quot; });    // O/P : &quot;1&quot; &quot;2&quot; &quot;1&quot; &quot;2&quot;
  </code></pre>
  <p>The above result are expected, but in the case of <code>List&lt;T&gt;</code> I am getting the same result from both <code>Union</code> and <code>Concat</code>.</p>
  <pre><code>class X
  {
      public int ID { get; set; }
  }
  
  class X1 : X
  {
      public int ID1 { get; set; }
  }
  
  class X2 : X
  {
      public int ID2 { get; set; }
  }
  
  var lstX1 = new List&lt;X1&gt; { new X1 { ID = 10, ID1 = 10 }, new X1 { ID = 10, ID1 = 10 } };
  var lstX2 = new List&lt;X2&gt; { new X2 { ID = 10, ID2 = 10 }, new X2 { ID = 10, ID2 = 10 } };
          
  var a5 = lstX1.Cast&lt;X&gt;().Union(lstX2.Cast&lt;X&gt;());     // O/P : a5.Count() = 4
  var a6 = lstX1.Cast&lt;X&gt;().Concat(lstX2.Cast&lt;X&gt;());    // O/P : a6.Count() = 4
  </code></pre>
  <p>But both are behaving the same incase of <code>List&lt;T&gt;</code>.</p>
  <p>Any suggestions please?</p>