How can I enumerate thee? Let me count the ways…
This weekend, I was writing some demo code for the async chapter of C# in Depth – the idea was to decompile a simple asynchronous method and see what happened. I received quite a surprise during this, in a way which had nothing to do with asynchrony. Given that at execution time, text refers to an instance of System.String, and assuming nothing in the body of the loop captures the ch variable, how would you expect the following loop to be compiled? foreach (char ch in text) { // Body here } Before today, I could think of four … Continue reading How can I enumerate thee? Let me count the ways…