C# Foreach statement does not contain public definition for GetEnumerator

后端 未结 4 1587
孤街浪徒
孤街浪徒 2021-02-07 00:33

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

4条回答
  •  太阳男子
    2021-02-07 01:01

    Your CarBootSaleList class is not a list. It is a class that contain a list.

    You have three options:

    Make your CarBootSaleList object implement IEnumerable

    or

    make your CarBootSaleList inherit from List

    or

    if you are lazy this could almost do the same thing without extra coding

    List>
    

提交回复
热议问题