views:

37

answers:

2

I have an instance variable with several members, many of which have their own members and so on. Using the debugger and watch variables, I found a string variable with a specific value that I need by diving into this variable's members.

However, after spending some time on other things and coming back to this, I am now unable to find where this value is located. When I have my application paused, is there a way to search the values of variables in the current context for a given value?

To clarify, if I have the given structure:

myVariable
|
|--aMember1
|  |--subMember = "A value"
|
|--aMember2
   |--subMember = "Another value"

Is there a way (possibly using the watch list in VS debugger) to search myVariable for any member or submember with the value "A value", returning to me the path myVariable->aMember->subMember?

+2  A: 

No this feature does not exist in Visual Studio 2008 (or any other version).

What you can do is add an ID for the value the first time you find it. Simply right click on the value and select "Make Object ID". This will create a unique identify that shows up in the value such as 1#. You can then type this value into the watch window at any future point and get the value to come back.

JaredPar
Is that identity for the value itself, or for the object reference? That is, if I type '1#' into my watch list after making an object ID, will the value of 1# change with the variable I got it from, or will it stay the same?
Aaron
Nevermind, I found the answer myself: http://geekswithblogs.net/sdorman/archive/2009/02/14/visual-studio-2008-debugging-ndash-the-watch-window.aspxThank you for your answer.
Aaron
A: 

You could type ?variable_name in the Immediate Window, which will print out everything on that variable, and then do a text search on the output.

Omer Raviv