Add a Property to the Top-level Statements Program class

The evolution of the C# language has introduced us to many new features and probably made a lot of folks re-evaluate how they write their apps. In the latest versions of .NET, nothing has been marked such a stylistic shift as the introduction of top-level statements.In this short post, we’ll examine how to add properties to your Program instance to improve the readability of utility console applications.Top-level statement filesWhen starting a new console application, you can create a Program.cs file and opt into the top-level statements style. The single line below is a valid .NET application.Console.WriteLine("Hello, World");At compile-time, the compiler generates the typical ceremony associated with traditional applications. Looking at our app’s low-level C# version, we’ll see the symbols we typically expect to see in a .NET app.using System;using System.Runtime.CompilerServices;[CompilerGenerated]internal class Program{ private static void $(string[] args) { Console.WriteLine...