Search code examples
visual-studio-2010visual-studiovisual-studio-debugging

Why doesn't the Locals window in Visual Studio show variable.Length?


I have the following C# variable and code:

string word;
...
if (word.Length > width)
...

During debugging in Visual Studio 2010, the Locals window shows word but word.Length is only available as a DataTip. Why is this, and is there a way to have the Locals window show such attributes as Length?

I am on Windows 7, Visual Studio 2010.


Solution

  • Because the Locals window show only local variables in current stack frame. Current stack frame can be selected in the Call Stack window.

    To get the value of "word.Length" expression, you can use the Autos window or Watch window. The Autos window displays variables used in the current statement and the previous statement. In Watch window you should manually add the "word.Length" expression.