The book is correct.
In .NET, the garbage collector has information of where in the code the variable is used, and as soon as it's unused, the object is eligible for garbage collection.
(However, if you run the code with a debugger attached, the garbage collector changes behaviour. It keeps the object for the entire scope of the variable, not only where the variable is used, so that the object can be investigated in the debugger.)