#846 – A Call Stack Keeps Track of Methods that Have Been Called
May 17, 2013 Leave a comment
When your application is running, Windows uses a stack data type to manage its call stack. A call stack is essentially just a record of the currently active methods. At the top of the stack is the current method that is executing. Below this method in the stack is the method that called the current method. At the bottom of the stack is the first method that began executing when your application started.
For example, if you have a Main method that calls method Dog.BarkYourAge and this method in turn calls a method named DogUtil.GenerateBark, the call stack will appear as follows during executing of GenerateBark. (For simplicity, we’re ignoring the .NET Framework methods that are called before invoking Main).
When a method is called, it is pushed onto the stack. When it returns to its calling method, it is popped off of the stack.