What's wrong with this code #4 - discussion...

I've decided to use "discussion" rather than "answer" on these.

So, in reference to the last question:

First, thanks to all who posted. The discussions in the comments are always interesting to read, and I usually learn something from them.

I was going for the call to GC.Collect(). The intention of the user was to clean up the NetworkResponse objects that came back from the call to GetNetwork().

This is almost always the wrong thing to do. Rico does a far better job discussing it here than I could.

So, that's what I was going for, but it looks like I'll need to take a bit more care in creating my examples, to limit the possibilities a bit.

To expand a bit on some of the comments:

There was a fair amount of discussion about resource leaks. Given what I wrote, there probably isn't enough information to determine whether a resource leak is an issue.

There was also a lot about data validation. Data validation is important when you're writing API routines and/or if you have security concerns, but my personal choice would be not to add data validation to this routine, because the runtime does a pretty good job in most cases. If, for example, the ArrayList is null, then the foreach loop is going to throw an exception without me checking.

The disadvantage of that approach is that the exception may not be quite as informative as a hand-coded one.

Hope that makes sense.