IEnumerator <T> serialization created using profit return

Is there a serialization method (using BinaryFormatter) IEnumerator<T>that is created when I use yield returns? Auto generation class is not marked Serializable.

+5
source share
3 answers

The compiler generated by enumerable does not have the [Serializable] attribute applied to it, so no, out of the box you cannot do this.

You must ask yourself: "Why am I using revenue here, and what does it mean when this object is deserialized?"

, , . , , / , .

+3

IEnumerable<T>? List<T> OK.

ToList() .

+3

Just list the enumerator and serialize each returned instance.

0
source

All Articles