In Visual Studio 2008, is there a way of finding all the variables that point to the same object as another variable?
So in the example below I would want to find out that ref1 and ref2 both point to the same object as original.
var original = new List<string>() { "Some Data" };
var ref1 = original;
var ref2 = ref1;
Essentially I want to be able to call ReferenceEquals() on all the variables in memory and then see all the ones that are equal. Except I want to be able to do this in the VS2008 IDE.
I just found a way of achieving what I wanted, and its all baked into VS2008.
If you hover over a variable while you’re debugging, right click on the tooltip and select ‘Make Object ID’
This gives that object an id (#1) that appears in the tooltip. So if you’ve got another variable that points to the same object it will have the same id (#1).