
See if you can spot the problem with the following C# code:
var list = new List
for (int i = 0; i < list.Count; i++)
{
list.Add(list[i].ToUpper());
}
As the title points out, this will cause an infinite loop, and will eat up all of your memory. What happens is that we iterate through the list once (i=0; list.Count = 3) and then add an element to the list. So the next loop we have (i=1; list.Count = 4). This is because anything in the parenthesis of the for operator will be evaluated every loop.
There are three options:
And the code was a dummy example code, nothing in use in any real system.
February is a busy month for me with several presentations and events going on:
Hope to see you at one or more of the events!
Earlier this year I gave two talks on Selling Software Craftsmanship in the Enterprise – one at the Software Craftsmanship North America conference, and one at Tampa BarCamp. The video from my presentation at Tampa BarCamp is now available. Enjoy!
Selling Software Craftsmanship in the Enterprise from Cory Foy on Vimeo.
Every year, Microsoft holds a conference called MIX for web developers and designers. This year they had an open call for sessions, and I was lucky enough to be able to submit four sessions. But I need your help – only the top 10 vote-getting sessions get in to MIX, and the voting ends January 15th. So take a few minutes and head over to http://visitmix.com/opencallvote and vote for your favorite sessions. Be sure to check out the sessions by Kevin Wolf, Justin Etheredge, Jim Zimmerman and Christopher Bennage as well. Thanks!