I have some unepected behavior and was hoping someone could shed some light on how the underlying pieces behind this code work to cause this issue.
The code below is intended to create a collection of an anonymous type in which during the creation an index is created for each object in the collection by incrementing the counter:
The problem is what ends up happening at run-time is every single time one "looks into the collection" either by stepping through and using a quick watch in the IDE, or a for each loop etc., the value of the index property increments.Code://Counter for key pair indexes var i = 0; //BuildKeyPairSet var keyPairs = from m in queryString select new { key = m.Key, val = m.Value, index = i++};
Any insight into why this is may not be aware of?
Thanks in advance!




Reply With Quote