Simplifying the usage of the console

In C# 6 and later, the using statement can be used to further simplify our code.

Add the following line to the top of the file:

using static System.Console; 

Now, we don't need to enter the Console type throughout our code. We can use Find and Replace to remove it.

Select the first Console. line in your code (ensure that you select the dot after the word Console).

In Visual Studio 2017, press Ctrl + H to do a quick replace (ensure that the Replace... box is empty), as shown in the following screenshot:

In Visual Studio Code, choose Edit, and then Replace, as shown in the following screenshot:

In both Visual ...

Get C# 7.1 and .NET Core 2.0 – Modern Cross-Platform Development - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.