What is the difference between "step over" and "step into" in Debugger mode?

Asked

Viewed 1,041 times

6

I wonder what the difference is between F10 (step over) and F11 (step into).

When should I wear F10 and when to use F11?

  • There is no way to know which shortcut is connected to those keys in your Visual Studio settings. What is the function name? You can see this in the settings, try CTRL+Q and search for shortcuts or shortcuts.

  • @Vinicius must be the standard function, almost no one changes it. I think we can consider it so unless he says he’s changed in his.

2 answers

7


In many lines the effect is the same, will change if you have any function on that line (some operators may not seem and are functions).

To F10 is called Stepping over and executes the line ignoring the implementation detail of the function on that line. Then the Debugger performs the function, but does not show you what is being done inside it, you do not enter the function visually.

To F11 is called Stepping into and in addition to performing the function it enters it visually and shows you what is running inside. You can navigate inside it and see the effects it will generate.

This will run recursively. So if you abuse it you almost get lost in the code. You should only enter functions that you really want to debug, if you use F11 too probably doing wrong thing during debugging.

The Debugger does not enter functions that it does not have the available source code. Even the sources of . NET can be optionally loaded in Visual Studio.

Configurações Visual Studio - Habilitar fontes do .NET

static void Main(string[] args) {     
    var x = Soma(1, 2); // <==== com F10 já pula pra próxima linha, com F11 entra em Soma()
    WriteLine(x); // <==== Só entra aqui com F11 se tiver os fontes do .NET carregados
}
static int Soma(int a, int b) => a + b;

I put in the Github for future reference.

Note that this "jumps to the next line" is only for debugging purposes, the execution will always enter the function and execute it.

Stepping over no Visual Studio

3

Let’s use the following example:

Public Sub PagarContas()
    Dim Valor = Calcular()
    EfetivarPagamento()
    ...
End Sub

Public Function Calcular() As Decimal
    Return 108.5 + 87.8
End Function

Your case Debugger stop in Calcular() and if you used Step Into (F11), you would enter the method definition Calcular() and debug it. If you used Step Over (F10), you would go through the method Calcular() without debugging it, visually, you would go straight to next line, which would be EfetivarPagamento().

Whether you use Step Over (F10) or Step Into (F11), the code will be executed. When it comes to skipping lines, it’s visual.

Links

Browser other questions tagged

You are not signed in. Login or sign up in order to post.