Enumerator Implementation: Use struct or class?
问题 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. 回答1: Like this others, I would choose a class. Mutable structs are nasty.