Welcome to MSDN Blogs Sign in | Join | Help

Donkblog

Adventures into the world of amateurgramming. I'll leave the programming to the professionals.
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;
   5:   
   6:  namespace Test
   7:  {
   8:      class Program
   9:      {
  10:          static int Foo()
  11:          {
  12:              return 4;
  13:          }
  14:   
  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.

registers

Posted: Wednesday, February 27, 2008 7:25 AM by Brandon Turner
Filed under:
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker