Link to home
Start Free TrialLog in
Avatar of curiouswebster
curiouswebsterFlag for United States of America

asked on

Trouble using 'foreach' with a generic list

I have not until now tried to use a foreach clause in a generic list. The compile error I get is:

foreach statement cannot operate on variables of type 'DMS.OrderNodeList' because 'DMS.OrderNodeList' does not contain a public definition for 'GetEnumerator'

Any suggestions what to do next?

Thanks,
newbieweb
ASKER CERTIFIED SOLUTION
Avatar of Reza Rad
Reza Rad
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You need to implement the IEnumerable interface in your custom collection (it is not a generic list).
Just implement the IEnumerator interface in your class and override the GetEnumerator().
It will work
Avatar of curiouswebster

ASKER

Thanks.