1 year ago

#374689

test-img

AlwaysLearning

Question about stack and local variables when calling methods

I'm learning C# from the book Head First C# and the following screenshot is taken from page 605. It's showing here what the stack looks like when calling methods.

As I understand from the book, when you call a method, its local variables will be stored on the stack temporarily until the method returns. Given the example in the book, I don't understand the following:

  1. Why isn't MealSize added to the stack before Capacity?
  2. Why are there 2 Bowl dogBowl on the stack? Shouldn't they be the same argument being passed?

Thank you so much for your help!!

enter image description here

c#

arguments

stack

0 Answers

Your Answer

Accepted video resources