Skip to content

How to stop change of objects in collection using c#.

sudheer tiwari

Asked May 8, 2015, 2:59 AM EDT1 answer
Share
LinkedInX
how to stop change of objects in collection using c#.

my object contains multiple collection. during serialization i am getting exception of Collection was modified; enumeration operation may not execute.

At time of serialization only i wants to control change of collection.

i use lock(this) and lock(SyncRoot) both are not working fine.

any alternate option for controlling changing behavior of collection during serialization only.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Pranay Rana
    0
    I suggest perform deep copy of your object and than serialize the newly created object...that will resolve your issue
    0