Working with collections
“foreach (Foo f in bar)” will do a dynamic cast to type Foo from the type returned by the IEnumerator for bar. No compile time warning is generated if bar returns a type that might be cast to Foo, i.e. if it’s a collection of Objects.
If there’s no possibility of casting to Foo, a compile time error occurs.
With a try block around the foreach, code execution in the debugger jumps ahead to an unexpected position which the try block instead of directly to the finally block. This appears to be a bug…
There are tools available for generating strongly typed collections.