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.CarBootSale
You don't show us the declaration of carBootSaleList. However from the exception message I can see that it is of type CarBootSaleList. This type doesn't implement the IEnumerable interface and therefore cannot be used in a foreach.
Your CarBootSaleList class should implement IEnumerable:
public class CarBootSaleList : IEnumerable
{
private List carbootsales;
...
public IEnumerator GetEnumerator()
{
return carbootsales.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return carbootsales.GetEnumerator();
}
}