“Make Object ID”, you can consider it as an another hidden features of Visual Studio that can give you lot of flexibility during debugging. When we set “Make Object ID” for an object, we are informing the Debugger to keep track of that object no matter it’s within scope or out of scope for the current context. You can create the “Object ID” either from Locals, Autos or from Watch Windows. Object ID is a integer number prefix by a dollar ($) sign. When we create Object ID for an particular object, Visual Studio Debugger use an integer value to uniquely identify the object. This “Object ID” allows you to get the object details even if it is out of scope.
Let’s try to understand with a very simple example, where we are iterating a set of string through a loop. If you inspect the value of “item” for first time it should be “name1”.
Now If you move to next items, there is no way to get the value of previous items. In that case you can just select “Make Object ID” for the selected object.
NOTE : This is a very simple object, You can apply this for any complex objects as well.
Object the Object ID is created, a $ < Value> will be added with the item.
Now, Let’s think you move to the next item in the collection.
Now, to access the previous value you can just type “$1” and it will show the value of previously tagged item associated with this object id.
Isn’t it cool. Just think about you want to try to access one object’s values which is already went out of scope. This is super powerful feature during debugging; You can even object / values across methods / modules.
Think about this following add-on. Your context moved to anther method, and there if you try to access “item” values; you will get message that “item” does not exist.
But, instead, when you are trying to access it with object it you have it live.
Refer to my one of detailed post the same subject line How to track an object which is Out of Scope while Debugging ?