SHARE:

Introducing C# 9: Top-level programs

Introduction

C# 9 introduces a super fun feature: Top-level programs. What’s a Top-level program ? This is a simpler way to write your program on its top level: a simpler Program.cs file

Before C# 9 and with C# 9

In your main program you have been able to write whatever you want, for example:

  • async calls (obviously)
  • accessing args (obviously)
  • local functions (obviously again !)

Imagine now, being able to do the same but in a simpler way ? it’s still possible with Top-level program feature. You will still be able to do the same:

No needs anymore to write class Program and void (or async Task) Main(string[] args). You will be able in the same way to call async code, accessing args before and even declare local functions and more!

Great isn’t it ? 😉

Written by

anthonygiretti

Anthony is a specialist in Web technologies (14 years of experience), in particular Microsoft .NET and learns the Cloud Azure platform. He has received twice the Microsoft MVP award and he is also certified Microsoft MCSD and Azure Fundamentals.
%d bloggers like this: