Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to inspect "this" object in Visual Studio while debugging?

When you debug your program, and for example you set a breakpoint as in here:

void foo(string s)
{
  (*) if (s=="bar")
  ...
}

(*) denotes breakpoint

you can move mouse cursor over "s" and inspect the content of it.

The question is how to do the same (i.e. inspect object) but not any argument or variable, but "this" object?

My case: I get exception at some point, I trace call stack, and let's say I would like to inspect "this" object of the 4th method of the call stack (for example).

like image 615
greenoldman Avatar asked Dec 30 '25 18:12

greenoldman


1 Answers

  1. Quick Watch Window

    • Right click in any place of window
    • In menu select "Quick Watch"
    • In text field enter this
    • Press OK
  2. Add Watch Window

    • Visual Studio menu -> Debug -> Windows -> Watch -> Watch 1
    • In opened Watch WIndow type in Name field this and press Enter
  3. Immediate Window

    • Visual Studio menu -> Debug -> Windows -> Immediate Window
    • Type this and press Enter
like image 145
sll Avatar answered Jan 02 '26 13:01

sll