title: Adding items to an IEnumerable through an extension method does not work?
body: <p>In most of the methods I use that return some kind of collection I return IEnumerable rather than the specific type (e.g. List). In many cases I have another collection that I want to combine with the result IEnumerable, this would be exactly like taking a List and adding another List to it using the AddRange method. I have the following example, in it I have created an extension method that should take a collection of items to add and adds them to a base collection, while debugging this appears to works but in the original collection the items are never added. I don't understand this, why aren't they added, is there something about the implementation of the IEnumerable that I am missing? I understand that IEnumerable is a read only interface, but Iam not adding to this list in the example below, I am replacing it, but the original IEnumerable does not change. </p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          var collectionOne = new CollectionContainerOne();
          var collectionTwo = new CollectionContainerTwo();
  
          // Starts at 1- 50 //
          collectionOne.Orders.AddRange(collectionTwo.Orders);
          // Should now be 100 items but remains original 50 //
      }
  }
  
  public class CollectionContainerOne
  {
      public IEnumerable&lt;Order&gt; Orders { get; set; }
  
      public CollectionContainerOne()
      {
          var testIds = Enumerable.Range(1, 50);
          var orders = new List&lt;Order&gt;();
          foreach (int i in testIds)
          {
              orders.Add(new Order() { Id = i, Name = "Order #" + i.ToString() });
          }
          this.Orders = orders;
      }
  }
  
  public class CollectionContainerTwo
  {
      public IEnumerable&lt;Order&gt; Orders { get; set; }
  
      public CollectionContainerTwo()
      {
          var testIds = Enumerable.Range(51, 50);
          var orders = new List&lt;Order&gt;();
          foreach (int i in testIds)
          {
              orders.Add(new Order() { Id = i, Name = "Order #" + i.ToString() });
          }
          this.Orders = orders;
      }
  }
  
  public class Order
  {
      public int Id { get; set; }
      public string Name { get; set; }
  
      public override string ToString()
      {
          return this.Name;
      }
  }
  
  public static class IEnumerable
  {
      public static void AddRange&lt;T&gt;(this IEnumerable&lt;T&gt; enumerationToAddTo, IEnumerable&lt;T&gt; itemsToAdd)
      {
          var addingToList = enumerationToAddTo.ToList();
          addingToList.AddRange(itemsToAdd);
  
          // Neither of the following works // 
          enumerationToAddTo.Concat(addingToList);
          // OR
          enumerationToAddTo = addingToList;
          // OR
          enumerationToAddTo = new List&lt;T&gt;(addingToList);
      }
  }
  </code></pre>