Enumerator Implementation: Use struct or class?

Posted by Hosam Aly on Stack Overflow See other posts from Stack Overflow or by Hosam Aly
Published on 2008-12-21T14:23:03Z Indexed on 2010/05/20 10:50 UTC
Read the original article Hit count: 432

Filed under:
|
|
|

I noticed that List<T> defines its enumerator as a struct, while ArrayList defines its enumerator as a class. What's the difference? If I am to write an enumerator for my class, which one would be preferable?

EDIT: My requirements cannot be fulfilled using yield, so I'm implementing an enumerator of my own. That said, I wonder whether it would be better to follow the lines of List<T> and implement it as a struct.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about c#