What is the difference between step over and step into debugger mode?

5

I would like to know what is the difference between F10 (step over) and F11 (step into).

When should I use F10 and when should I use F11 ?

    
asked by anonymous 09.02.2017 / 00:49

2 answers

6

In many lines the effect is the same, it will change if you have some function on that line (some operators may not look like they are functions).

F10 is called stepping over and runs the line ignoring the implementation detail of the function on that line. Then the debugger runs the function but does not show you what is being done inside it, you do not enter the function visually.

F11 is called stepping into and in addition to running the function it goes into it visually and shows you what is running in there. You can navigate within it and see what effects it is generating.

This runs recursively. So if you abuse yourself you almost get lost in the code. You should only enter functions that you really want to debug, if you use F11 else you are probably doing something wrong while debugging.

debugger does not go into functions that it does not have the source code available. Even .NET fonts can optionally be loaded into Visual Studio.

staticvoidMain(string[]args){varx=Soma(1,2);//<====comF10jápulaprapróximalinha,comF11entraemSoma()WriteLine(x);//<====SóentraaquicomF11setiverosfontesdo.NETcarregados}staticintSoma(inta,intb)=>a+b;

Notethatthis"jump to next line" is just for debugging purposes, execution will always go into the function and execute it.

    
09.02.2017 / 01:04
2

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

If your debugger stopped at Calcular() and you used Step Into (F11), you would enter the Calcular() method definition and debug it. If you used Step Over (F10), you would go through the Calcular() method without debugging it, visually, you would go straight to the next line, which would be EfetivarPagamento() .

  

Regardless of 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

09.02.2017 / 01:10