O'Reilly logo

C# Data Structures and Algorithms by Marcin Jamro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing to output

Now, you know how to read input data, but how can you ask questions to the user or present results on the screen? The answer, together with examples, is shown in this section.

Similarly as in the case of reading data, operations related to the standard output stream are performed using methods of the Console static class from the System namespace, namely Write and WriteLine. Let's see them in action!

To write some text, you can just call the Write method, passing the text as a parameter. An example of code is as follows:

Console.Write("Enter a name: "); 

The preceding line causes the following output to be shown:

    Enter a name: 

What's important here is that the written text is not followed by the line terminator. If you ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required