Quantcast
Channel: 2,000 Things You Should Know About C# » Visual Studio
Viewing all articles
Browse latest Browse all 21

#848 – Viewing the Call Stack in Visual Studio

$
0
0

The call stack keeps track of the currently executing method in your application, and from where that method was called.  You can use the debugger in Visual Studio to view the current call stack when you are in break mode (at a breakpoint or stepping through your code).

If the call stack is not already visible, click on the Debug menu, then Windows and Call Stack.  (Or press Ctrl+D, C).

848-001

In the example below, we’ve started the application and are located in our Main method, which was called by native code.

848-002

If we now step into the Dog.BarkYourAge method, the call stack shows this method on the top of the stack, with Main as the second entry.  Main is just below BarkYourAge in the stack, because it called BarkYourAge.

848-003

If BarkYourAge then calls DogUtil.GenerateBark and we step into that method, we see:

848-004

If we return from GenerateBark, we see:

848-005


Filed under: Visual Studio Tagged: C#, Call Stack, Visual Studio

Viewing all articles
Browse latest Browse all 21

Trending Articles