From the course: Debugging in C#
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
What is a print statement?
- [Kathryn] A print statement allows you to send output to the standard output unit of your computer, usually your console or terminal. You've probably used print statements all along, but here we'll put them into context with debugging. Here we have Visual Studio Code open, and in C#, a print statement looks like this. We have Console.WriteLine, with whatever we want to print out in the parentheses. We also add using System at the top in order to get access to the console so we can print data to it. Let's go ahead and run this code, and this is just a hello world application. You've probably done this dozens of times, but with debugging it can get a little bit more complicated. With this statement, we're just printing out a hardcoded value, which isn't super useful. In debugging, sometimes we'll want to print the value of a given variable to understand more fully how our program is working. So let's go ahead and add an int a, which we'll give the value 10, and int b, which we'll give…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
What is debugging?2m 1s
-
(Locked)
What is a print statement?2m 1s
-
(Locked)
What is a breakpoint?5m 59s
-
(Locked)
Inspecting values of variables4m 28s
-
(Locked)
Execution in debug mode3m 40s
-
(Locked)
The debugging process2m 11s
-
(Locked)
Beginner debugging code challenge1m 13s
-
(Locked)
Beginner debugging code challenge: Solution6m 45s
-
-
-
-
-