Write it using yield return
.
As to why you might otherwise choose between class
or struct
, if you make it a struct
then it gets boxed as soon as it is returned as an interface, so making it a struct
just causes additional copying to take place. Can't see the point of that!