question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New Project Templates for top-level programs in C# 9

See original GitHub issue

With C# 9 on the horizon, we are already able to start building top-level programs in C#:

I think it would make sense to build a new project template that includes a top-level program in C# with a Program.cs file and a csproj file. The code in the Program.cs file would be as simple as this:

using System;

await Console.Out.WriteLineAsync("Hello, World!");

Before I built the PR, I want to ask if this was something your team was willing to consider at this point?

There’s some exciting stuff happening in this space, and it would be great to point people at a simple template to get started. I even saw some of the ASP.NET team on Twitter showing off top-level programs that host a simple HTTP API in a few lines of code.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
vlada-shubinacommented, Mar 11, 2022

This was already done for .NET 6. The templates are using top-level programs now. Closing

1reaction
genaltcommented, Jul 30, 2020

@seesharprun thank you for the proposal, at the current stage of the .Net 5 release, we are not going to add a new template to the SDK. But you can add it yourself and I will update the list of available templates, maintained by the community. From our side we can include these changes only into our template in the next major .Net release (and C# 10).

I am keeping this issue open.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Top-level statements - C# tutorial
This tutorial shows how you can use top-level statements to experiment and prove concepts while exploring your ideas.
Read more >
C# console app template generates top-level statements
The .NET 6+ project template for C# console apps uses top-level statements. Understand what changed and how to use existing learning ...
Read more >
Tiny top-level programs with C# 9 and SmallSharp and ...
The template "Console Application" was created successfully ... Right now Visual Studio only supports one top-level program per project.
Read more >
How to use top-level programs in C# 9
Click on “Create new project.” In the “Create new project” window, select “Console App (.NET Core)” from the list of templates displayed. Click ......
Read more >
Top Level Programs In C# 9 - NET Core Tutorials
A Console Application Today. Start any new console application today from Visual Studio, and you'll see something like this : using ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found