title: C# Foreach statement does not contain public definition for GetEnumerator
body: <p>I'm having a problem with a Windows Form application I'm building in C#. The error is stating "foreach statement cannot operate on variables of type 'CarBootSale.CarBootSaleList' because 'CarBootSale.CarBootSaleList' does not contain a public definition for 'GetEnumerator'".</p>
  
  <p>I can't seem to understand what is causing this.</p>
  
  <p>This is the code that is throwing up the error:</p>
  
  <pre><code>        List&lt;CarBootSaleList&gt; Sortcarboot = new List&lt;CarBootSaleList&gt;();
  
          foreach (CarBootSale c in carBootSaleList)
          {
              if (c.Charity == "N/A")
              {
                  Sortcarboot.Add(carBootSaleList);
                  textReportGenerator.GenerateAllReport(Sortcarboot, AppData.CHARITY);
              }
          }
  </code></pre>
  
  <p>and this is the CarBootSaleList class where it's saying there isn't a GetEnumerator definition:</p>
  
  <pre><code>public class CarBootSaleList
  {
  
      private List&lt;CarBootSale&gt; carbootsales;
  
      public CarBootSaleList()
      {
          carbootsales = new List&lt;CarBootSale&gt;();
      }
  
      public bool AddCarBootSale(CarBootSale carbootsale)
      {
          bool success = true;
          foreach (CarBootSale cbs in carbootsales)
          {
              if (cbs.ID == carbootsale.ID)
              {
                  success = false;
              }
          }
          if (success)
          {
              carbootsales.Add(carbootsale);
          }
          return success;
      }
  
      public void DeleteCarBootSale(CarBootSale carbootsale)
      {
          carbootsales.Remove(carbootsale);
      }
  
      public int GetListSize()
      {
          return carbootsales.Count();
      }
  
      public List&lt;CarBootSale&gt; ReturnList()
      {
          return carbootsales;
      }
  
      public string Display()
      {
          string msg = "";
  
          foreach (CarBootSale cbs in carbootsales)
          {
              msg += String.Format("{0}  {1}", cbs.ID, cbs.Location, cbs.Date);
              msg += Environment.NewLine;
          }
          return msg;
      }
  </code></pre>