Below is a very simple, trainer-friendly debugging demo you can use live in class to
explain breakpoints, along with step-by-step explanation and what learners should
observe.
🎯 DEMO GOAL
👉 Show how breakpoints pause execution and allow us to inspect values step-by-step
🧪 SIMPLE DEBUGGING DEMO (C#
Console App)
📌 Scenario
We will calculate total salary and debug how values change.
🧾 STEP 1: SAMPLE CODE (VERY SIMPLE)
using System;
class Program
{
static void Main()
{
int basicSalary = 20000;
int hra = 8000;
int tax = 3000;
int totalSalary = CalculateTotalSalary(basicSalary, hra, tax);
[Link]("Total Salary is: " + totalSalary);
[Link]();
}
static int CalculateTotalSalary(int basic, int hra, int tax)
{
int grossSalary = basic + hra;
int netSalary = grossSalary - tax;
return netSalary;
}
}
🧭 STEP 2: SETTING A BREAKPOINT
🎙️ What to Say
“A breakpoint tells the program:
Pause here. Do not execute further until I say so.”
✅ Action
👇
1. Open this file in Visual Studio
2. Click on the left margin of this line
int totalSalary = CalculateTotalSalary(basicSalary, hra, tax);
🔴 A red dot appears → breakpoint set
▶️ STEP 3: START DEBUGGING
✅ Action
▶️
● Press F5
(or click Start Debugging)
🎙️ What Happens
“The program starts running…
and pauses exactly at the breakpoint.”
🧠 STEP 4: INSPECT VARIABLES (MOST
IMPORTANT PART)
🎙️ Say This Slowly
“Now the program is frozen in time.
Let’s inspect what data it is holding.”
👀 Observe in IDE
Hover mouse over variables:
basicSalary → 20000
hra → 8000
tax → 3000
“These values exist before the method call.”
⏭️ STEP 5: STEP OVER (F10)
✅ Action
● Press F10 (Step Over)
🎙️ Explanation
“Step Over executes the current line
but does not go inside the method.”
Now execution moves to:
[Link]("Total Salary is: " + totalSalary);
Hover:
totalSalary → 25000
🔍 STEP 6: STEP INTO (F11)
Reset and try again
● Restart Debugging (Shift + F5, then F5)
● Breakpoint again
● This time press F11 (Step Into)
🎙️ Explain
“Step Into goes inside the method to see how logic works.”
Execution moves into:
int grossSalary = basic + hra;
Inspect:
basic → 20000
hra → 8000
grossSalary → 28000
Next line:
netSalary → 25000
🧰 STEP 7: WATCH WINDOW (OPTIONAL
BUT POWERFUL)
🎙️ Say This
“Watch window lets us monitor variables continuously.”
✅ Action
● Right-click grossSalary
● Add to Watch
“Now it updates automatically as execution moves.”
🏁 STEP 8: CONTINUE EXECUTION
● Press F5 again
Output:
Total Salary is: 25000
🧠 KEY CONCEPTS TO EMPHASIZE
(EXAM / INTERVIEW)
🎯 Breakpoint
“A breakpoint pauses execution at a specific line.”
🎯 Step Over (F10)
“Executes the line without entering methods.”
🎯 Step Into (F11)
“Moves inside method calls.”
🎯 Debugging Purpose
“Debugging helps us understand behavior, not just fix errors.”
🎤 STRONG CLOSING LINE (Use This)
“Debugging is like X-ray vision for code.
Instead of guessing what went wrong,
we see exactly what is happening.”
✅ If you want next:
🔹 Debugging a buggy program (logical error demo)
🔹 Breakpoints in Web API
●
●
🔹 Conditional breakpoints
🔹 Interview questions on debugging
●
●
Just tell me 👍