When debugging in VS 2008 why does the debugger land on a second return statement?

Posted by Hellfire on Stack Overflow See other posts from Stack Overflow or by Hellfire
Published on 2010-04-30T18:26:15Z Indexed on 2010/04/30 18:27 UTC
Read the original article Hit count: 156

Filed under:
|
|

When debugging the following console program:

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(DoIt(false));

        Console.WriteLine(DoIt(true));
    }

    private static Boolean DoIt(Boolean abort)
    {
        try {
            throw new InvalidOperationException();
        } catch(Exception ex) {
            if (abort) {
                return true;
            }

            Console.WriteLine("Got here");
            return false;
        }
    }
}

Why does the IDE land on the second return statement during the second call to DoIt()? The results of the execution is correct but the debugging experience is misleading.

Is this a known issue?

Is the behavior in VS 2010 the same?

© Stack Overflow or respective owner

Related posts about visual-studio-2008

Related posts about debugging