finding c# memory addresses using visual studio debugger

i'd like to find the addresses of 2 variables to make sure it's not the same address.

i did this easily using c++ and breakpoints in the debugger but i can't find the variable addresses in c#.

thanks.

matt



Answer this question

finding c# memory addresses using visual studio debugger

  • hismightiness

    You can test if two variables are referencing the same object by using the Object.Equals method. You can use the immediate window to run the test, if you need. In the .NET Runtime, the physical memory addresses of objects may change when the garbage collector runs, and so the debugger does not display physical memory addresses. The only time the addresses should ever matter is if you're using 'unsafe' memory operations, so I'm not sure if there is a way to get the debugger to divulge that information.


  • finding c# memory addresses using visual studio debugger