Execution always takes place within the context of a method, also known as the containing method or current method. When execution pauses, Visual Studio calls the debug engine (DE) to get a list of local variables and arguments, collectively called the locals of the method. Visual Studio displays these locals and their values in the Locals window.
To display locals, the DE calls the GetMethodProperty method belonging to the EE and gives it an evaluation context, that is, a symbol provider (SP), the current execution address, and a binder object. For more information, see Evaluation context. If the call succeeds, the IDebugExpressionEvaluator::GetMethodProperty method returns an IDebugProperty2 object, which represents the method that contains the current execution address.
The DE calls EnumChildren to get an IEnumDebugPropertyInfo2 object, which is filtered to return only locals and enumerated to produce a list of DEBUG_PROPERTY_INFO structures. Each structure contains the name, type, and value of a local. The type and value are stored as formatted strings, suitable for display. The name, type, and value are typically displayed together in one line of the Locals window.
Note
The QuickWatch and Watch windows also display variables with the same format of name, value, and type. However, those values are obtained by calling GetPropertyInfo instead of IDebugProperty2::EnumChildren.
Learn how to efficiently debug your .NET app by using Visual Studio to fix your bugs quickly. Use the interactive debugger within Visual Studio to analyze and fix your C# applications.
Inspect variables in the Autos and Locals windows while debugging in Visual Studio. The Autos and Locals windows show variable values while you are debugging.
While you debug, see variables and expressions in Watch and QuickWatch. Watch can display several variables, QuickWatch only one, and only while in break.
There are many types of debugger windows that provide you with information. This article provides a list of the types. For each, there's a link to more information.