c# - How to check that a dictionary / collection can be iterated over? -


I have some code that works on the dictionary and the simple linq functions to find some important values ​​within the dictionary Uses, but recently I'm getting the following error ...

  Invalid Operation exception: The operation is not valid due to the current state of the object system. Linac america ITate [KeyValuePair`2, Int32] (IEnumerable`1 source, Int32 initValue, System.Func`3 selector)  

How do I confirm that the operation is safe and avoid this error ?

Because of the code sample problem ...

  Public Zero UpdateBounds () {Lock (Voxels) {Start = New IntVector3 (Voxels.Min (v = & gt; V.Key.X), Voxels.Min (V => v.Key.Y), Voxels.Min (v => v.Key.Z)); End = new intravator 3 (voxel max (v => v.kay.x), voxels.max (v => v.kay.y), voxels.max (v => v.key .Z)); }}  

It seems that you are performing an operation on an empty dictionary object . / P>

Check that before executing that statement it contains anything dictionary is your man.


Comments