Checking Return Values Without Saving Them


Often times I will be debugging some code and I want to see a return value of a function; but the value of the function is not saved into a variable for one reason or another. 

In the simplest form you can see this scenario in the following code:

    1:  using System;
    2:  using System.Collections.Generic;
    3:  using System.Linq;
    4:  using System.Text;
    6:  namespace Test
    7:  {
    8:      class Program
    9:      {
   10:          static int Foo()
   11:          {
   12:              return 4;
   13:          }
   15:          static void Main(string[] args)
   16:          {
   17:              Foo();
   18:          }
   19:      }
   20:  }

If I want to see the value that is returned from the function call to Foo(), I can start by setting a breakpoint on line 18.  Then I go to the menu bar and follow the path 'Debug'->'Windows'->'Registers'.  You can see that the EAX register will contain the return value even though I didn't save the return value to a variable.