“using” blocks are often written like this:
using (new Foo()) { ... }
rather than like this:
using (var f = new Foo()) { ... }
In the first case, where no explicit reference to the new Foo object is set, is there any danger that the object could be disposed prior to the end of the block? If not, why not?
No you don’t need to set an explicit reference, unless you need to access the object with the scope block. There is no danger of the unreferenced variable being disposed early because it is only disposed of when it goes out of scope.