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?

What is a print statement?

From the course: Debugging in C#

Start my 1-month free trial

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…

Contents