Seven Things about C#

A beginners tutorial, where each article highlights 7 important things about a specific feature of the C# programming language.

Member-only story

7 Things about C#: Console I/O

--

A dark, but cute and furry, cat looking animal.

The console is the command line, where you type commands to run code and get a response. In general terms, input and output (I/O) describe the interactions of information being given to the program (input) and information that the program emits.

These interactions are often communication with a user, but can also be communication with other programs. We won’t get that elaborate here, but will describe some interesting I/O capabilities that you can use in a C# application to communicate with people.

1 — There are different ways to write

The Console class has two writing methods: Write and WriteLine. The difference is that WriteLine adds a new line after printing and Write doesn’t. Here’s an example:

Console.WriteLine("Console I/O Demo\n");

Console.WriteLine("\t 1. Door #1");
Console.WriteLine("\t 2. Door #2");
Console.WriteLine("\t Q. Quit");

Console.Write("\nYour Choice (1, 2, or Q): ");

You’ve seen Console.WriteLine in the previous post on Running Apps. However, there are a few differences here, specifically in the strings with escape, \, characters, which are special instructions to the terminal. The first line contains a newline escape, \n, which adds a line in the terminal where it appears. This example has the effect of adding two newlines because one is…

--

--

Seven Things about C#
Seven Things about C#

Published in Seven Things about C#

A beginners tutorial, where each article highlights 7 important things about a specific feature of the C# programming language.

Joe Mayo
Joe Mayo

Written by Joe Mayo

Author, Instructor, & Independent Consultant. Author of C# Cookbook: — http://bit.ly/CSharpCookbook — @OReillyMedia #ai #csharp #Web3

Responses (1)